Last active
December 27, 2016 13:11
-
-
Save calebkleveter/c0391cdbfeda09254475609a7f302a70 to your computer and use it in GitHub Desktop.
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
func adminLogin(_ request: Request)throws -> ResponseRepresentable { | |
guard let username = request.data["username"]?.string, | |
let password = request.data["password"]?.string else { | |
throw Abort.badRequest | |
} | |
let credentials = UsernamePassword(username: username, password: password) | |
do { | |
try request.auth.login(credentials, persist: true) | |
return Response(redirect: "/admin/new-post") | |
} catch { | |
return Response(redirect: "/login?succeded=false") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment