Skip to content

Commit e300ee9

Browse files
feat: fix auth for SaaS template (#95)
* feat: fix auth * ci: fmt
1 parent b6dd80c commit e300ee9

File tree

1 file changed

+5
-2
lines changed
  • fullstack-templates/saas/backend/src

1 file changed

+5
-2
lines changed

fullstack-templates/saas/backend/src/auth.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ pub async fn login(
5858

5959
match query.await {
6060
Ok(res) => {
61-
if bcrypt::verify(login.password, res.get("password")).is_err() {
62-
return Err(StatusCode::BAD_REQUEST);
61+
match bcrypt::verify(login.password, res.get("password")) {
62+
Ok(true) => {}
63+
Ok(false) => return Err(StatusCode::BAD_REQUEST),
64+
Err(_) => return Err(StatusCode::BAD_REQUEST),
6365
}
66+
6467
let session_id = rand::random::<u64>().to_string();
6568

6669
sqlx::query("INSERT INTO sessions (session_id, user_id) VALUES ($1, $2) ON CONFLICT (user_id) DO UPDATE SET session_id = EXCLUDED.session_id")

0 commit comments

Comments
 (0)