You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-29 22:01:14 +03:00
storage: ensure the repository trait can be boxed
and define some wrappers to map the errors
This commit is contained in:
@ -104,10 +104,12 @@ impl UpstreamOAuth2Link {
|
||||
} else {
|
||||
// Fetch on-the-fly
|
||||
let mut repo = PgRepository::from_pool(ctx.data::<PgPool>()?).await?;
|
||||
repo.upstream_oauth_provider()
|
||||
let provider = repo
|
||||
.upstream_oauth_provider()
|
||||
.lookup(self.link.provider_id)
|
||||
.await?
|
||||
.context("Upstream OAuth 2.0 provider not found")?
|
||||
.context("Upstream OAuth 2.0 provider not found")?;
|
||||
provider
|
||||
};
|
||||
|
||||
Ok(UpstreamOAuth2Provider::new(provider))
|
||||
@ -121,10 +123,12 @@ impl UpstreamOAuth2Link {
|
||||
} else if let Some(user_id) = &self.link.user_id {
|
||||
// Fetch on-the-fly
|
||||
let mut repo = PgRepository::from_pool(ctx.data::<PgPool>()?).await?;
|
||||
repo.user()
|
||||
let user = repo
|
||||
.user()
|
||||
.lookup(*user_id)
|
||||
.await?
|
||||
.context("User not found")?
|
||||
.context("User not found")?;
|
||||
user
|
||||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
@ -67,7 +67,9 @@ impl User {
|
||||
) -> Result<Option<UserEmail>, async_graphql::Error> {
|
||||
let mut repo = PgRepository::from_pool(ctx.data::<PgPool>()?).await?;
|
||||
|
||||
Ok(repo.user_email().get_primary(&self.0).await?.map(UserEmail))
|
||||
let mut user_email_repo = repo.user_email();
|
||||
|
||||
Ok(user_email_repo.get_primary(&self.0).await?.map(UserEmail))
|
||||
}
|
||||
|
||||
/// Get the list of compatibility SSO logins, chronologically sorted
|
||||
|
Reference in New Issue
Block a user