Last active
February 3, 2017 16:31
-
-
Save johnkors/968e060dd5771a00708a4f48fdbc3b25 to your computer and use it in GitHub Desktop.
POST /core/discourse/login
This file contains hidden or 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
[Route("core/discourse/login")] | |
[HttpPost] | |
[ValidateAntiForgeryToken] | |
public ActionResult Login(string username, string password) | |
{ | |
if (Users.PasswordMatch(username, password)) | |
{ | |
var user = Users.GetUser(username); | |
var authLogin = new AuthenticatedLogin | |
{ | |
AuthenticationMethod = "password", | |
Name = user.GetClaim("name"), | |
Subject = user.Subject, | |
PersistentLogin = true | |
}; | |
Request.GetOwinContext().Environment.IssueLoginCookie(authLogin); | |
var sso = TempData["sso"] as string; | |
TempData["sso"] = null; | |
var redirectUrl = CreateDiscourseRedirectUrl(user, sso); | |
return new RedirectResult(redirectUrl); | |
} | |
TempData["error"] = "Wrong username or password"; | |
return View("Index"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment