public async Task <ActionResult> EnrollPhoneAuthenticatorAsync(EnrollPhoneViewModel model) { if (!ModelState.IsValid) { model.MethodTypes = (List <AuthenticatorMethodType>)Session["methodTypes"]; return(View("EnrollPhoneAuthenticator", model)); } try { var enrollPhoneAuthenticatorOptions = new EnrollPhoneAuthenticatorOptions { AuthenticatorId = Session["phoneId"].ToString(), PhoneNumber = model.PhoneNumber, MethodType = model.MethodType, }; var enrollResponse = await _idxClient.EnrollAuthenticatorAsync(enrollPhoneAuthenticatorOptions, (IIdxContext)Session["IdxContext"]); Session["IdxContext"] = enrollResponse.IdxContext; if (enrollResponse.AuthenticationStatus == AuthenticationStatus.AwaitingAuthenticatorVerification) { return(RedirectToAction("VerifyAuthenticator", "Manage")); } return(View("EnrollPhoneAuthenticator", model)); } catch (OktaException exception) { ModelState.AddModelError(string.Empty, exception.Message); model.MethodTypes = (List <AuthenticatorMethodType>)Session["methodTypes"]; return(View("EnrollPhoneAuthenticator", model)); } }
public ActionResult EnrollPhoneAuthenticator() { var methodTypes = (List <AuthenticatorMethodType>)Session["methodTypes"] ?? new List <AuthenticatorMethodType>(); var model = new EnrollPhoneViewModel { MethodTypes = methodTypes, MethodType = methodTypes.FirstOrDefault(), }; return(View(model)); }