You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
template: more cleanups
This commit is contained in:
@ -107,7 +107,7 @@ pub async fn get(
|
||||
return Ok((cookie_jar, Html(content)).into_response());
|
||||
}
|
||||
|
||||
let ctx = CompatSsoContext::new(login, PostAuthAction::continue_compat_sso_login(id))
|
||||
let ctx = CompatSsoContext::new(login)
|
||||
.with_session(session)
|
||||
.with_csrf(csrf_token.form_value());
|
||||
|
||||
|
@ -101,7 +101,7 @@ pub(crate) async fn get(
|
||||
.await?;
|
||||
|
||||
if res.valid() {
|
||||
let ctx = ConsentContext::new(grant, PostAuthAction::continue_grant(grant_id))
|
||||
let ctx = ConsentContext::new(grant)
|
||||
.with_session(session)
|
||||
.with_csrf(csrf_token.form_value());
|
||||
|
||||
@ -109,7 +109,7 @@ pub(crate) async fn get(
|
||||
|
||||
Ok((cookie_jar, Html(content)).into_response())
|
||||
} else {
|
||||
let ctx = PolicyViolationContext::new(grant, PostAuthAction::continue_grant(grant_id))
|
||||
let ctx = PolicyViolationContext::new(grant)
|
||||
.with_session(session)
|
||||
.with_csrf(csrf_token.form_value());
|
||||
|
||||
|
@ -163,7 +163,7 @@ pub(crate) async fn get(
|
||||
|
||||
(Some(user_session), None) => {
|
||||
// Session not linked, but user logged in: suggest linking account
|
||||
let ctx = UpstreamSuggestLink::new(link.id)
|
||||
let ctx = UpstreamSuggestLink::new(&link)
|
||||
.with_session(user_session)
|
||||
.with_csrf(csrf_token.form_value());
|
||||
|
||||
@ -182,7 +182,7 @@ pub(crate) async fn get(
|
||||
(None, None) => {
|
||||
// Session not linked and used not logged in: suggest creating an
|
||||
// account or logging in an existing user
|
||||
let ctx = UpstreamRegister::new(link.id).with_csrf(csrf_token.form_value());
|
||||
let ctx = UpstreamRegister::new(&link).with_csrf(csrf_token.form_value());
|
||||
|
||||
templates.render_upstream_oauth2_do_register(&ctx).await?
|
||||
}
|
||||
|
@ -61,10 +61,7 @@ pub(crate) async fn get(
|
||||
let ctx = ReauthContext::default();
|
||||
let next = query.load_context(&mut conn).await?;
|
||||
let ctx = if let Some(next) = next {
|
||||
// SAFETY: we should have an action only if we have a "next" context
|
||||
// TODO: make that cleaner
|
||||
let action = query.post_auth_action.unwrap();
|
||||
ctx.with_post_action(next, action)
|
||||
ctx.with_post_action(next)
|
||||
} else {
|
||||
ctx
|
||||
};
|
||||
|
@ -38,22 +38,22 @@ impl OptionalPostAuthAction {
|
||||
self.go_next_or_default(&mas_router::Index)
|
||||
}
|
||||
|
||||
pub async fn load_context<'e>(
|
||||
pub async fn load_context(
|
||||
&self,
|
||||
conn: &mut PgConnection,
|
||||
) -> anyhow::Result<Option<PostAuthContext>> {
|
||||
let Some(action) = self.post_auth_action.clone() else { return Ok(None) };
|
||||
let ctx = match action {
|
||||
PostAuthAction::ContinueAuthorizationGrant { data } => {
|
||||
let grant = get_grant_by_id(conn, data)
|
||||
PostAuthAction::ContinueAuthorizationGrant { id } => {
|
||||
let grant = get_grant_by_id(conn, id)
|
||||
.await?
|
||||
.context("Failed to load authorization grant")?;
|
||||
let grant = Box::new(grant);
|
||||
PostAuthContextInner::ContinueAuthorizationGrant { grant }
|
||||
}
|
||||
|
||||
PostAuthAction::ContinueCompatSsoLogin { data } => {
|
||||
let login = get_compat_sso_login_by_id(conn, data)
|
||||
PostAuthAction::ContinueCompatSsoLogin { id } => {
|
||||
let login = get_compat_sso_login_by_id(conn, id)
|
||||
.await?
|
||||
.context("Failed to load compat SSO login")?;
|
||||
let login = Box::new(login);
|
||||
|
Reference in New Issue
Block a user