chg: Added some checks during deletion of a shortlink

This commit is contained in:
SinTan1729
2024-03-13 18:59:10 -05:00
parent aa097ad982
commit 5ecd29926d
3 changed files with 16 additions and 5 deletions

View File

@@ -114,8 +114,11 @@ async fn delete_link(
session: Session,
) -> HttpResponse {
if auth::validate(session) {
database::delete_link(shortlink.to_string(), &data.db);
HttpResponse::Ok().body("")
if utils::delete_link(shortlink.to_string(), &data.db) {
HttpResponse::Ok().body(format!("Deleted {shortlink}"))
} else {
HttpResponse::NotFound().body("Not found!")
}
} else {
HttpResponse::Forbidden().body("Wrong password!")
}