c# - How can i Get Role Type after i successfully Login -
how role type after login credentials here sample db
id name psw role 1 john 123 admin oathcode worte code in startup.cs
public class startup { public void configuration(iappbuilder app) { var myprovider = new myauthorizationserverprovider(); oauthauthorizationserveroptions options = new oauthauthorizationserveroptions { allowinsecurehttp = true, tokenendpointpath = new pathstring("/token"), accesstokenexpiretimespan = timespan.fromhours(1), provider = myprovider }; app.useoauthauthorizationserver(options); app.useoauthbearerauthentication(new oauthbearerauthenticationoptions()); httpconfiguration config = new httpconfiguration(); webapiconfig.register(config); } } this authencation page here i'm crosschecking user myauthorizationserverprovider.cs class
public class myauthorizationserverprovider: oauthauthorizationserverprovider { icrendentials objcredential = new crendentials(); logincrediential objuser = new logincrediential(); public override async task validateclientauthentication(oauthvalidateclientauthenticationcontext context) { context.validated(); // } public override async task grantresourceownercredentials(oauthgrantresourceownercredentialscontext context) { var identity = new claimsidentity(context.options.authenticationtype); if (context.username!=null && context.password !=null) { var x = objcredential.emailvalidation(context.username, context.password); if (x==true) { identity.addclaim(new claim(claimtypes.role,context.username)); identity.addclaim(new claim("username", context.username)); identity.addclaim(new claim(claimtypes.name, "sourav mondal")); context.validated(identity); } } else { context.seterror("invalid_grant", "provided username , password incorrect"); return; } when login username=john , password=123, grant_type=password.im getting access_token as: sometoken, "token_type": "bearer","expires_in": 1day here need role admin or thing pease me how can role type
Comments
Post a Comment