-
-
Save BitPuffin/f1bbdc79ff312a67f2e8 to your computer and use it in GitHub Desktop.
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
| post "/user/personalogin": | |
| let ass = request.params["assertion"] | |
| if ass == "": | |
| halt(Http400, "assertion was not found in the request") | |
| let data: PJsonNode = %{"assertion": %ass, "audience": %(audiencePrefix & hostname & ":" & $port)} | |
| let response = httpclient.post(personaVerifier, "Content-Type: application/json\c\L", body=($data)) | |
| if response.status == "200 OK": | |
| let verificationData = parseJson(response.body) | |
| if $verificationData["status"].str == "okay": | |
| # TODO: Set this to a secure cookie (an hmac) | |
| let email = $verificationData["email"] | |
| setCookie(userCookie, email, daysForward(7)) | |
| if not isUser(email): | |
| redirect("/signup") | |
| else: | |
| # TODO: Redirect to current page instead | |
| redirect("/") | |
| else: | |
| halt(Http500, "Something went wrong when authenticating") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment