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
log in where? how?
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
so this is an exercise? (not like school but like your test)
why don't you post what you have tried
its kinda complicated since i had to manipule a lot of files
i can try
this is my class, the one i want to have the login
wich includes identityuser
this is my aplicationdbcontext
and this is my program.cs
@not guilty
on the toturial ive saw, theyve done this
adding the scafflolding item
this is the error
are you following a tutorial? i don't use identity itself, but it looks like you are missing some stuff
like
AddUserManager<>()
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
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
which is kind of really important :p
@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
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 thingso 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
I dont get notified, but you dont need to ping
aight bro
apreciatte your time 🙂
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
Ill try it
But isnt like just install8ng and changing the identity type for my class?
I don't understand the question