Is IPrinciple the way to go?

jNormenjNormen SEMember ✭✭

Hi, Is IPrinciple still a good practice in Xmarin form apps?
I want to save some information regarding the login user to be used within the application. Like a userid or roles as claims. I have this information in my JWT.

I know I can save this data to a SecureStorage or Localstorage or Sqlite and so on. But then I need to implement all the other stuff like IsinRole etc...
I tried to google IPrinciple and Xamarin to find anyone talking about this but nothing.

Thread.CurrentPrincipal

Is this still a good pattern to go with as long the user is online in the application?

My idea is:
When user login I save the access token in SecureStorage for communication with REST APIas. Then I create my IPrinciple based on the payload information and add it to the Thread to be used within the application itself with Thread.CurrentPrincipal.

Tagged:
Sign In or Register to comment.