Skip to content

Commit

Permalink
feat: account verify (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
K0nnyaku authored Dec 3, 2024
1 parent 6abc5bc commit 1a6e441
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/routes/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,21 @@ pub async fn login(
.into())
}

#[post("/verify", data = "<data>")]
pub async fn verify(db: &State<Surreal<Client>>, data: Json<OwnedCredentials>) -> Result<Empty> {
if session::verify(db, &data.id, &data.token).await {
Ok(Response {
success: true,
message: "Verified successfully".into(),
data: None,
}
.into())
} else {
Err(Error::Unauthorized(Json("Invalid credentials".into())))
}
}

pub fn routes() -> Vec<rocket::Route> {
use rocket::routes;
routes![register, profile, get_profile, delete, login]
routes![register, profile, get_profile, delete, login, verify]
}

0 comments on commit 1a6e441

Please sign in to comment.