1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-20 12:02:22 +03:00

storage: ensure the repository trait can be boxed

and define some wrappers to map the errors
This commit is contained in:
Quentin Gliech
2023-01-19 19:10:35 +01:00
parent 876bc9fcb3
commit f4c64c2171
23 changed files with 801 additions and 142 deletions

View File

@@ -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);
};