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: split the repository trait
This commit is contained in:
@ -28,7 +28,9 @@ use mas_data_model::{BrowserSession, User, UserEmail};
|
||||
use mas_email::Mailer;
|
||||
use mas_keystore::Encrypter;
|
||||
use mas_router::Route;
|
||||
use mas_storage::{user::UserEmailRepository, BoxClock, BoxRepository, BoxRng, Clock, Repository};
|
||||
use mas_storage::{
|
||||
user::UserEmailRepository, BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
|
||||
};
|
||||
use mas_templates::{AccountEmailsContext, EmailVerificationContext, TemplateContext, Templates};
|
||||
use rand::{distributions::Uniform, Rng};
|
||||
use serde::Deserialize;
|
||||
@ -71,7 +73,7 @@ async fn render<E: std::error::Error>(
|
||||
templates: Templates,
|
||||
session: BrowserSession,
|
||||
cookie_jar: PrivateCookieJar<Encrypter>,
|
||||
repo: &mut (impl Repository<Error = E> + ?Sized),
|
||||
repo: &mut impl RepositoryAccess<Error = E>,
|
||||
) -> Result<Response, FancyError> {
|
||||
let (csrf_token, cookie_jar) = cookie_jar.csrf_token(clock, rng);
|
||||
|
||||
@ -88,7 +90,7 @@ async fn render<E: std::error::Error>(
|
||||
|
||||
async fn start_email_verification<E: std::error::Error + Send + Sync + 'static>(
|
||||
mailer: &Mailer,
|
||||
repo: &mut (impl Repository<Error = E> + ?Sized),
|
||||
repo: &mut impl RepositoryAccess<Error = E>,
|
||||
mut rng: impl Rng + Send,
|
||||
clock: &impl Clock,
|
||||
user: &User,
|
||||
|
@ -26,7 +26,7 @@ use mas_keystore::Encrypter;
|
||||
use mas_storage::{
|
||||
upstream_oauth2::UpstreamOAuthProviderRepository,
|
||||
user::{BrowserSessionRepository, UserPasswordRepository, UserRepository},
|
||||
BoxClock, BoxRepository, BoxRng, Clock, Repository,
|
||||
BoxClock, BoxRepository, BoxRng, Clock, RepositoryAccess,
|
||||
};
|
||||
use mas_templates::{
|
||||
FieldError, FormError, LoginContext, LoginFormField, TemplateContext, Templates, ToFormState,
|
||||
@ -161,7 +161,7 @@ pub(crate) async fn post(
|
||||
// TODO: move that logic elsewhere?
|
||||
async fn login(
|
||||
password_manager: PasswordManager,
|
||||
repo: &mut (impl Repository + ?Sized),
|
||||
repo: &mut impl RepositoryAccess,
|
||||
mut rng: impl Rng + CryptoRng + Send,
|
||||
clock: &impl Clock,
|
||||
username: &str,
|
||||
@ -235,7 +235,7 @@ async fn render(
|
||||
ctx: LoginContext,
|
||||
action: OptionalPostAuthAction,
|
||||
csrf_token: CsrfToken,
|
||||
repo: &mut (impl Repository + ?Sized),
|
||||
repo: &mut impl RepositoryAccess,
|
||||
templates: &Templates,
|
||||
) -> Result<String, FancyError> {
|
||||
let next = action.load_context(repo).await?;
|
||||
|
@ -33,7 +33,7 @@ use mas_policy::PolicyFactory;
|
||||
use mas_router::Route;
|
||||
use mas_storage::{
|
||||
user::{BrowserSessionRepository, UserEmailRepository, UserPasswordRepository, UserRepository},
|
||||
BoxClock, BoxRepository, BoxRng, Repository,
|
||||
BoxClock, BoxRepository, BoxRng, RepositoryAccess,
|
||||
};
|
||||
use mas_templates::{
|
||||
EmailVerificationContext, FieldError, FormError, RegisterContext, RegisterFormField,
|
||||
@ -233,7 +233,7 @@ async fn render(
|
||||
ctx: RegisterContext,
|
||||
action: OptionalPostAuthAction,
|
||||
csrf_token: CsrfToken,
|
||||
repo: &mut (impl Repository + ?Sized),
|
||||
repo: &mut impl RepositoryAccess,
|
||||
templates: &Templates,
|
||||
) -> Result<String, FancyError> {
|
||||
let next = action.load_context(repo).await?;
|
||||
|
@ -18,7 +18,7 @@ use mas_storage::{
|
||||
compat::CompatSsoLoginRepository,
|
||||
oauth2::OAuth2AuthorizationGrantRepository,
|
||||
upstream_oauth2::{UpstreamOAuthLinkRepository, UpstreamOAuthProviderRepository},
|
||||
Repository,
|
||||
RepositoryAccess,
|
||||
};
|
||||
use mas_templates::{PostAuthContext, PostAuthContextInner};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -42,7 +42,7 @@ impl OptionalPostAuthAction {
|
||||
|
||||
pub async fn load_context<'a>(
|
||||
&'a self,
|
||||
repo: &'a mut (impl Repository + ?Sized),
|
||||
repo: &'a mut impl RepositoryAccess,
|
||||
) -> anyhow::Result<Option<PostAuthContext>> {
|
||||
let Some(action) = self.post_auth_action.clone() else { return Ok(None) };
|
||||
let ctx = match action {
|
||||
|
Reference in New Issue
Block a user