C
C#9mo ago
Setforex

Identity struggle

I started learning C# a short time ago, I wanted to try to log in using the identity embedded in a class created by me, but I'm not getting it, if someone can give me an explanation or help me do it I would be grateful 😅
22 Replies
this_is_pain
this_is_pain9mo ago
log in where? how?
Setforex
SetforexOP9mo ago
just a simple example would be nice i want to know how to do it with in a class that i have create imagine i have the class Doctor i want each doctor to have is own login ive tried a couple times and i couldnt do it @not guilty sry for ping bro, idk if you get notified if i just respond
this_is_pain
this_is_pain9mo ago
so this is an exercise? (not like school but like your test) why don't you post what you have tried
Setforex
SetforexOP9mo ago
its kinda complicated since i had to manipule a lot of files i can try
Setforex
SetforexOP9mo ago
this is my class, the one i want to have the login
No description
Setforex
SetforexOP9mo ago
wich includes identityuser
Setforex
SetforexOP9mo ago
this is my aplicationdbcontext
No description
Setforex
SetforexOP9mo ago
and this is my program.cs
No description
Setforex
SetforexOP9mo ago
@not guilty on the toturial ive saw, theyve done this adding the scafflolding item
Setforex
SetforexOP9mo ago
No description
Setforex
SetforexOP9mo ago
this is the error
this_is_pain
this_is_pain9mo ago
are you following a tutorial? i don't use identity itself, but it looks like you are missing some stuff like AddUserManager<>()
Setforex
SetforexOP9mo ago
i think soo, i asked chat for help he told me to make some changes in some files that i dont even have but he told me to do scafoolding and the files didnt got created meanwhile i will keep trying bro but thx for your time ❤️ @not guilty
Pobiega
Pobiega9mo ago
have you checked out https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-8.0&tabs=net-cli ? your program.cs code starts out almost identical, but you skipped setting up your cookie and identity options you also didnt call
app.UseAuthentication();
app.UseAuthentication();
which is kind of really important :p
Setforex
SetforexOP9mo ago
@Pobiega i really apreciate your help, im not home at the moment i will try following that toturial if i have any doubt after can i ping you? other think is like ive seen in that link that he doesnt use a class my objective is to make a class to be associated to the login
Pobiega
Pobiega9mo ago
just specify your own class instead of IdentityUser otherwise its the same you gotta understand that most things build on other things, you dont need an entirely new tutorial just to tweak a tiny thing
Setforex
SetforexOP9mo ago
so its like i just gotta create a project with individual accounts and the associate the identity user to my own class? @Pobiega sry for the ping, i just dont know if you get notified if i write here
Pobiega
Pobiega9mo ago
I dont get notified, but you dont need to ping
Setforex
SetforexOP9mo ago
aight bro apreciatte your time 🙂
Pobiega
Pobiega9mo ago
the problem in your current code is that you skipped 2 very important steps the most important was to actually enable the middleware for authentication (thus disabling all of identity...) but not configuring the cookie also causes issues, like wrong redirect when visiting an unauthorized endpoint
Setforex
SetforexOP9mo ago
Ill try it But isnt like just install8ng and changing the identity type for my class?
Pobiega
Pobiega9mo ago
I don't understand the question

Did you find this page helpful?