Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [<HttpPost>]
- member x.Login (viewModel:LoginViewModel) =
- if String.IsNullOrWhiteSpace viewModel.UserName || String.IsNullOrWhiteSpace viewModel.Password then
- x.ModelState.AddModelError("", "Incorrect username or password")
- if x.ModelState.IsValid then
- let userToGet = ctx.Users |> Seq.tryFind(fun z -> z.UserName = viewModel.UserName && z.Password = viewModel.Password)
- match userToGet with
- | Some u ->
- FormsAuthentication.SetAuthCookie(u.UserName, false)
- x.RedirectToAction "index" :> ActionResult
- | None -> HttpNotFoundResult() :> ActionResult
- else x.View("login", viewModel) :> ActionResult
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement