public virtual async Task <IdentityResult> ConfirmPhoneNumberAsync(string userId, string code) { ApplicationUser user = await FindByIdAsync(userId); if (user == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ApplicationMessages.UserIdNotFound)); } IdentityResult identityResult; if (!AuthyApiClient.VerifyToken(user.AuthyUserId, code).Success) { identityResult = IdentityResult.Failed(ApplicationMessages.InvalidVerificationCode); } else { IUserPhoneNumberStore <ApplicationUser, string> store = (IUserPhoneNumberStore <ApplicationUser, string>)Store; await store.SetPhoneNumberConfirmedAsync(user, true); identityResult = await UpdateAsync(user); } return(identityResult); }
private async Task RegisterAsAuthyUser(ApplicationUser user) { string authyUserId = AuthyApiClient.RegisterUser(user.Email, user.PhoneNumber.Replace(String.Format("+{0}", user.CountryCode), string.Empty), Convert.ToInt32(user.CountryCode)).UserId; user.AuthyUserId = authyUserId; await UpdateAsync(user); }
public virtual async Task RequestPhoneNumberConfirmationTokenAsync(string userId) { ApplicationUser user = await FindByIdAsync(userId); if (user == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ApplicationMessages.UserIdNotFound)); } if (String.IsNullOrEmpty(user.AuthyUserId)) { await RegisterAsAuthyUser(user); } AuthyApiClient.SendSms(user.AuthyUserId, force: true); }
public static void Main(string[] args) { AuthyApiClient api = new AuthyApiClient(); }