Skip to content

Instantly share code, notes, and snippets.

@eldewall
Created November 28, 2013 13:37
Show Gist options
  • Save eldewall/7691966 to your computer and use it in GitHub Desktop.
Save eldewall/7691966 to your computer and use it in GitHub Desktop.
dry?
[Authorize]
[OutputCache(NoStore = false, Duration = 0, Location = OutputCacheLocation.None)]
public ActionResult AuthorizeBankId(string returnUrl)
{
BankIdValidator = new BankIdValidator(this.CurrentUser, this.UserRepository);
var url = !String.IsNullOrEmpty(returnUrl) ? returnUrl : Url.Action("Index", "Home");
if (this.CurrentUser.IsBankIDAuthorized)
{
return Redirect(url);
}
BankIdModel model = new BankIdModel();
var response = BankIdValidator.BeginAuth(this.CurrentUser.SocialSecurityNumber);
model.OrderRef = response.OrderRef;
model.ReturnUrl = url;
model.Message = response.Message;
model.Action = StatusResponse.ClientActionType.Nothing.ToString();
model.IsDone = false;
return View(model);
}
[OutputCache(NoStore = false, Duration = 0, Location = OutputCacheLocation.None)]
public JsonResult BankIdStart() {
BankIdValidator = new BankIdValidator(this.CurrentUser, this.UserRepository);
BankIdModel model = new BankIdModel();
var response = BankIdValidator.BeginAuth(this.CurrentUser.SocialSecurityNumber);
model.OrderRef = response.OrderRef;
model.Message = response.Message;
model.Action = response.ClientAction.ToString();
model.HasError = response.ClientAction != StatusResponse.ClientActionType.Nothing;
model.IsDone = false;
return Json(model, JsonRequestBehavior.AllowGet);
}
[OutputCache(NoStore = false, Duration = 0, Location = OutputCacheLocation.None)]
public JsonResult BankIdStatus(string orderRef)
{
BankIdValidator = new BankIdValidator(this.CurrentUser, this.UserRepository);
BankIdModel model = new BankIdModel();
var status = BankIdValidator.Status(orderRef);
model.Message = status.Message;
model.Action = status.ClientAction.ToString();
model.OrderRef = orderRef;
model.IsDone = status.IsDone;
model.HasError = status.ClientAction != StatusResponse.ClientActionType.Nothing;
return Json(model, JsonRequestBehavior.AllowGet);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment