public ActionResult LoginFinish(string returnUrl) { ViewBag.ReturnUrl = returnUrl; var sequrePhraseQuestion = GetSecurePhraseQuestionFromTempData(); var model = new LoginFinishViewModel() { PhraseFirstCharNumber = GetCharacterArb(sequrePhraseQuestion.FirstCharacterIndex), PhraseSecondCharNumber = GetCharacterArb(sequrePhraseQuestion.SecondCharacterIndex), SecurityToken = sequrePhraseQuestion.SecurityToken, }; return View(model); }
private SecurePhraseAnswer GetSecurePhraseAnswer(LoginFinishViewModel model) { return new SecurePhraseAnswer() { FirstCharacter = model.PhraseFirstChar.ToArray().FirstOrDefault(), SecondCharacter = model.PhraseSecondChar.ToArray().FirstOrDefault(), }; }
private ActionResult TryAuthenticateUser(LoginFinishViewModel model, string returnUrl) { try { return AuthenticateUser(model, returnUrl); } catch (InvalidSecurePhraseAnswer) { AddModelStateError(GlobalStrings.SecurePhraseSymbolsAreInvalid); } catch (NotAuthenticatedException) { AddModelStateError(GlobalStrings.YouNeedToEnterMailAndPasswordFirst); } catch (Exception ex) { AddModelStateError(GlobalStrings.SomethingWentWrong); } return View(model); }
private ActionResult AuthenticateUser(LoginFinishViewModel model, string returnUrl) { var securePhraseAnswer = GetSecurePhraseAnswer(model); var authenticatedUser = FinishUserLogin(model.SecurityToken, securePhraseAnswer); RemoveStepCookie(); if (authenticatedUser.Role == Role.Admin) return RedirectToAction("Index", "UserManagement"); if (authenticatedUser.Role == Role.CaseWorker) return RedirectToAction("Index", "Complaints"); return RedirectToLocal(returnUrl); }
public ActionResult LoginFinish(LoginFinishViewModel model, string returnUrl) { if (ModelState.IsValid) { return TryAuthenticateUser(model, returnUrl); } // If we got this far, something failed, redisplay form return View(model); }