mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 13:01:12 +03:00
Added a feature to create temporary users
- Token verification simplified
This commit is contained in:
parent
4bd9a2ab2e
commit
7594e3d615
7 changed files with 60 additions and 45 deletions
|
|
@ -27,15 +27,9 @@ async fn verify(
|
|||
Token(token): Token,
|
||||
State(state): State<AppState>,
|
||||
) -> Response {
|
||||
match token {
|
||||
Some(t) => {
|
||||
if !state.config.lock().await.verify_token(&t) {
|
||||
return (StatusCode::UNAUTHORIZED, "wrong token".to_string()).into_response()
|
||||
}
|
||||
},
|
||||
None => return (StatusCode::UNAUTHORIZED, "unauthorized".to_string()).into_response(),
|
||||
}
|
||||
(StatusCode::OK, "ok".to_string()).into_response()
|
||||
state.config.lock().await.clone()
|
||||
.verify_token(&token)
|
||||
.unwrap_or_else(|x| x)
|
||||
}
|
||||
|
||||
async fn raw(
|
||||
|
|
@ -45,13 +39,9 @@ async fn raw(
|
|||
body: String,
|
||||
) -> Response {
|
||||
debug!(body = body);
|
||||
match token {
|
||||
Some(t) => {
|
||||
if !state.config.lock().await.verify_token(&t) {
|
||||
return (StatusCode::UNAUTHORIZED, "wrong token".to_string()).into_response()
|
||||
}
|
||||
},
|
||||
None => return (StatusCode::UNAUTHORIZED, "unauthorized".to_string()).into_response(),
|
||||
match state.config.lock().await.clone().verify_token(&token) {
|
||||
Ok(_) => {},
|
||||
Err(e) => return e,
|
||||
}
|
||||
let payload = match hex::decode(body) {
|
||||
Ok(v) => v,
|
||||
|
|
@ -85,13 +75,9 @@ async fn sub_raw(
|
|||
body: String,
|
||||
) -> Response {
|
||||
debug!(body = body);
|
||||
match token {
|
||||
Some(t) => {
|
||||
if !state.config.lock().await.verify_token(&t) {
|
||||
return (StatusCode::UNAUTHORIZED, "wrong token".to_string()).into_response()
|
||||
}
|
||||
},
|
||||
None => return (StatusCode::UNAUTHORIZED, "unauthorized".to_string()).into_response(),
|
||||
match state.config.lock().await.clone().verify_token(&token) {
|
||||
Ok(_) => {},
|
||||
Err(e) => return e,
|
||||
}
|
||||
let payload = match hex::decode(body) {
|
||||
Ok(v) => v,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue