Created
November 28, 2013 13:37
-
-
Save eldewall/7691966 to your computer and use it in GitHub Desktop.
dry?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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