public async Task <bool> VerifyTwoFactorTokenAsync(TwoFactorTokenType tokenType, int userid, string token, bool updateSecurityStamp = false)
 {
     if (await VerifyUserTokenAsync(userid, tokenType.ToString(), token))
     {
         // update security stamp, this will invalidate any other tokens
         if (updateSecurityStamp)
         {
             await UpdateSecurityStampAsync(userid);
         }
         return(true);
     }
     return(false);
 }
Example #2
0
 /// <summary>
 /// Verifies the unique hashed token sent to the user
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="tokenType">Type of the token.</param>
 /// <param name="userid">The userid.</param>
 /// <param name="code">The code.</param>
 /// <param name="updateSecurityStamp">if set to <c>true</c> update the users security stamp. This will invalidate any other active tokens</param>
 protected async Task <bool> VerifyUserTwoFactorTokenAsync(TwoFactorTokenType tokenType, string userid, string code, bool updateSecurityStamp = false)
 {
     if (await UserManager.FindByIdAsync(userid) != null)
     {
         if (await UserManager.VerifyUserTokenAsync(userid, tokenType.ToString(), code))
         {
             // update security stamp, this will invalidate any other tokens
             if (updateSecurityStamp)
             {
                 await UserManager.UpdateSecurityStampAsync(userid);
             }
             return(true);
         }
     }
     return(false);
 }
 public Task <string> GenerateTwoFactorTokenAsync(TwoFactorTokenType tokenType, int userid)
 {
     return(GenerateUserTokenAsync(tokenType.ToString(), userid));
 }
Example #4
0
 /// <summary>
 /// Generates unique hashed token based on the users security stamp to be sent via email.
 /// </summary>
 /// <param name="manager">The usermanager.</param>
 /// <param name="tokenType">Type of the token.</param>
 /// <param name="userid">The userid.</param>
 protected async Task <string> GenerateUserTwoFactorTokenAsync(TwoFactorTokenType tokenType, string userid)
 {
     return(await UserManager.GenerateUserTokenAsync(tokenType.ToString(), userid));
 }
Example #5
0
 /// <summary>
 /// Generates unique hashed token based on the users security stamp to be sent via email.
 /// </summary>
 /// <param name="manager">The usermanager.</param>
 /// <param name="tokenType">Type of the token.</param>
 /// <param name="userid">The userid.</param>
 public async Task <string> GenerateUserTwoFactorTokenAsync(TwoFactorTokenType tokenType, string userid)
 {
     return(await GenerateUserTokenAsync(tokenType.ToString(), userid));
 }