fix userinfo endpoint

This commit is contained in:
Denys Konovalov 2021-08-09 22:09:20 +02:00
parent 64ed9cdfe7
commit 0b52ca8eef

@ -22,7 +22,6 @@ use keycloak::KeycloakError;
use rocket::fs::{relative, FileServer};
use rocket::http::Status;
use rocket::response::status;
use rocket::http;
use rocket::request::{FromRequest, Outcome, Request};
use std::error::Error;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
@ -245,7 +244,7 @@ async fn get_userinfo(credentials: Json<Credentials>) -> Result<Json<KeycloakUse
credentials.otp.clone(),
)
.await;
let mut token = match keycloak_resp {
let token = match keycloak_resp {
Ok(token) => Token {
outcome: TokenOutcome {
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
}