mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-12 02:25:41 +00:00
frontend: logout and add sitekey
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use actix_identity::Identity;
|
||||
use actix_web::http::header;
|
||||
use actix_web::{get, post, web, HttpResponse, Responder};
|
||||
use log::debug;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -246,12 +247,14 @@ pub async fn set_email(
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
#[post("/api/v1/signout")]
|
||||
#[get("/logout")]
|
||||
pub async fn signout(id: Identity) -> impl Responder {
|
||||
if let Some(_) = id.identity() {
|
||||
id.forget();
|
||||
}
|
||||
HttpResponse::Ok()
|
||||
HttpResponse::TemporaryRedirect()
|
||||
.set_header(header::LOCATION, "/login")
|
||||
.body("")
|
||||
}
|
||||
|
||||
/// Check if user is authenticated
|
||||
|
||||
@@ -124,13 +124,13 @@ async fn auth_works() {
|
||||
// 5. signout
|
||||
let signout_resp = test::call_service(
|
||||
&mut app,
|
||||
test::TestRequest::post()
|
||||
.uri("/api/v1/signout")
|
||||
test::TestRequest::get()
|
||||
.uri("/logout")
|
||||
.cookie(cookies)
|
||||
.to_request(),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(signout_resp.status(), StatusCode::OK);
|
||||
assert_eq!(signout_resp.status(), StatusCode::TEMPORARY_REDIRECT);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
|
||||
Reference in New Issue
Block a user