fix userinfo endpoint
This commit is contained in:
parent
64ed9cdfe7
commit
0b52ca8eef
@ -22,7 +22,6 @@ use keycloak::KeycloakError;
|
|||||||
use rocket::fs::{relative, FileServer};
|
use rocket::fs::{relative, FileServer};
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use rocket::response::status;
|
use rocket::response::status;
|
||||||
use rocket::http;
|
|
||||||
use rocket::request::{FromRequest, Outcome, Request};
|
use rocket::request::{FromRequest, Outcome, Request};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
@ -245,7 +244,7 @@ async fn get_userinfo(credentials: Json<Credentials>) -> Result<Json<KeycloakUse
|
|||||||
credentials.otp.clone(),
|
credentials.otp.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
let mut token = match keycloak_resp {
|
let token = match keycloak_resp {
|
||||||
Ok(token) => Token {
|
Ok(token) => Token {
|
||||||
outcome: TokenOutcome {
|
outcome: TokenOutcome {
|
||||||
status: TokenStatus::Success,
|
status: TokenStatus::Success,
|
||||||
@ -280,8 +279,12 @@ async fn get_userinfo(credentials: Json<Credentials>) -> Result<Json<KeycloakUse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let outcome = match token.outcome.status {
|
||||||
|
TokenStatus::Success => Ok(Json(get_keycloak_userinfo(token.token.clone()).await.unwrap())),
|
||||||
|
_ => Err(status::Unauthorized::<()>(None))
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Json(get_keycloak_userinfo(token.token.clone()).await.unwrap()))
|
outcome
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user