You've already forked AstralRinth
forked from didirus/AstralRinth
Auth fixes (#664)
* Auth fixes * destroy flows after use * fix comp err * add bearer err msg
This commit is contained in:
@@ -1197,6 +1197,7 @@ pub async fn login_from_minecraft(
|
||||
access_token: token,
|
||||
}) = flow
|
||||
{
|
||||
Flow::remove(&login.flow, &redis).await?;
|
||||
let provider = AuthProvider::Microsoft;
|
||||
let oauth_user = provider.get_user(&token).await?;
|
||||
let user_id_opt = provider.get_user_id(&oauth_user.id, &**client).await?;
|
||||
|
||||
@@ -64,6 +64,12 @@ pub async fn route(
|
||||
x.value_mut().clone()
|
||||
};
|
||||
|
||||
ws_conn_try!(
|
||||
"Removing login flow" StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Flow::remove(code, &redis).await
|
||||
=> ws_conn
|
||||
);
|
||||
|
||||
let access_token = ws_conn_try!(
|
||||
"OAuth token exchange" StatusCode::INTERNAL_SERVER_ERROR,
|
||||
stages::access_token::fetch_token(
|
||||
@@ -122,7 +128,7 @@ pub async fn route(
|
||||
let flow = &ws_conn_try!(
|
||||
"Error creating microsoft login request flow." StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Flow::MicrosoftLogin {
|
||||
access_token: bearer_token.clone(),
|
||||
access_token: access_token.access_token.clone(),
|
||||
}
|
||||
.insert(Duration::hours(1), &redis)
|
||||
.await
|
||||
|
||||
@@ -22,6 +22,6 @@ pub async fn fetch_bearer(token: &str, uhs: &str) -> Result<String, Authenticati
|
||||
.and_then(serde_json::Value::as_str)
|
||||
.map(String::from)
|
||||
.ok_or(AuthenticationError::Custom(
|
||||
"Response didn't contain valid bearer token".to_string(),
|
||||
format!("Response didn't contain valid bearer token. body: {body}"),
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user