c# - Check if phone number confirmed when a user wanted to login via oauth token -


this appoauthprovider.cs oauth provider

everything login via oauth

but want check if user not confirmed it's phone number, , send token it's phone before login

 public override task validateclientauthentication(oauthvalidateclientauthenticationcontext context)     {         string clientid = string.empty;         string clientsecret = string.empty;         identityuser client = null;          if (!context.trygetbasiccredentials(out clientid, out clientsecret))             context.trygetformcredentials(out clientid, out clientsecret);          // resource owner password credentials not provide client id.         if (context.clientid == null)         {             context.validated();             return task.fromresult<object>(null);         }          // here check if client not active         client = _userservice().findidentitybyid(context.clientid) identityuser;         if (client == null)         {             context.seterror(string.format("کاربر '{0}' در سامانه عضو نیست.", context.clientid));             return task.fromresult<object>(null);         }          var usermanager = context.owincontext.getusermanager<applicationusermanager>();         var isphoneconfirmed = usermanager.isphonenumberconfirmedasync(client.id);         if (!isphoneconfirmed.result)         {             // confirm phone number             var sendcode = _userservice().sendphoneverifycodeasync(client.username);             context.seterror(sendcode.result ? errormessages.confirmphone : errormessages.phonetokensenderror);             return task.fromresult<object>(null);         }          context.validated();         return task.fromresult<object>(null);     } 

this code returns:

"error": "invalid_grant"


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -