Skip to content

Commit

Permalink
Remove debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Jun 14, 2024
1 parent 6ede85c commit 50940a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/puck/routes.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ pub fn handle_request(req: Request, ctx: Context) -> Response {
["information"] -> event.information(req, ctx)
["sign-up", key] if key == attend -> auth.sign_up(req, ctx)
["login"] -> auth.login(req, ctx)
["login", user_id, token] -> {
io.debug("login via token")
auth.login_via_token(user_id, token, ctx)
}
["login", user_id, token] -> auth.login_via_token(user_id, token, ctx)
["api", "payment", key] if key == pay -> money.payment_webhook(req, ctx)
_ -> wisp.not_found()
}
Expand Down
10 changes: 2 additions & 8 deletions src/puck/web/auth.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,16 @@ pub fn login_via_token(user_id: String, token: String, ctx: Context) {
// This application isn't very sensitive, so we're just comparing tokens
// rather than doing the much more secure thing of storing and comparing
// a hash in a constant time way.
io.debug(0)
use user_id <- web.try_(int.parse(user_id), bad_token_page)
io.debug(1)
use db_token <- web.try_(
user.get_login_token(ctx.db, user_id),
bad_token_page,
)
io.debug(2)
use db_token <- web.some(db_token, bad_token_page)
io.debug(3)
case io.debug(token == db_token) {
case token == db_token {
True ->
wisp.redirect("/")
|> response.set_header("x-louis", "hello!!!!")
|> set_signed_user_id_cookie(user_id, ctx.config.signing_secret)
|> io.debug
False -> bad_token_page()
}
}
Expand Down Expand Up @@ -232,7 +226,7 @@ fn set_signed_user_id_cookie(
) -> Response {
<<int.to_string(user_id):utf8>>
|> crypto.sign_message(<<signing_secret:utf8>>, crypto.Sha256)
|> response.set_cookie(response, auth_cookie, _, cookie.defaults(Https))
|> response.set_cookie(response, auth_cookie, _, cookie.defaults(http.Http))
}

pub fn get_user_from_session(
Expand Down

0 comments on commit 50940a2

Please sign in to comment.