Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 789040d

Browse files
committed
graphql: Fix the createOauth2Session mutation not persisting the changes to the database
1 parent 9c97a0c commit 789040d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

crates/graphql/src/mutations/oauth2_session.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ impl OAuth2SessionMutations {
199199
Some(refresh_token)
200200
};
201201

202+
repo.save().await?;
203+
202204
Ok(CreateOAuth2SessionPayload {
203205
session,
204206
access_token: access_token.access_token,

crates/handlers/src/graphql/tests.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ use axum::http::Request;
1616
use hyper::StatusCode;
1717
use mas_data_model::{AccessToken, Client, TokenType, User};
1818
use mas_router::SimpleRoute;
19-
use mas_storage::{oauth2::OAuth2ClientRepository, RepositoryAccess};
19+
use mas_storage::{
20+
oauth2::{OAuth2AccessTokenRepository, OAuth2ClientRepository},
21+
RepositoryAccess,
22+
};
2023
use oauth2_types::{
2124
registration::ClientRegistrationResponse,
2225
requests::AccessTokenResponse,
@@ -551,4 +554,17 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
551554
assert!(response.errors.is_empty(), "{:?}", response.errors);
552555
assert!(response.data["createOauth2Session"]["refreshToken"].is_null());
553556
assert!(response.data["createOauth2Session"]["accessToken"].is_string());
557+
558+
let token = response.data["createOauth2Session"]["accessToken"]
559+
.as_str()
560+
.unwrap();
561+
562+
// We should find this token in the database
563+
let mut repo = state.repository().await.unwrap();
564+
let token = repo
565+
.oauth2_access_token()
566+
.find_by_token(token)
567+
.await
568+
.unwrap();
569+
assert!(token.is_some());
554570
}

0 commit comments

Comments
 (0)