You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-08-09 04:22:45 +03:00
Show a proper 'link expired' page
This commit is contained in:
@@ -1056,6 +1056,39 @@ impl TemplateContext for RecoveryProgressContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Context used by the `pages/recovery/expired.html` template
|
||||
#[derive(Serialize)]
|
||||
pub struct RecoveryExpiredContext {
|
||||
session: UserRecoverySession,
|
||||
}
|
||||
|
||||
impl RecoveryExpiredContext {
|
||||
/// Constructs a context for the recovery expired page
|
||||
#[must_use]
|
||||
pub fn new(session: UserRecoverySession) -> Self {
|
||||
Self { session }
|
||||
}
|
||||
}
|
||||
|
||||
impl TemplateContext for RecoveryExpiredContext {
|
||||
fn sample(now: chrono::DateTime<Utc>, rng: &mut impl Rng) -> Vec<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
let session = UserRecoverySession {
|
||||
id: Ulid::from_datetime_with_source(now.into(), rng),
|
||||
email: "name@mail.com".to_owned(),
|
||||
user_agent: UserAgent::parse("Mozilla/5.0".to_owned()),
|
||||
ip_address: None,
|
||||
locale: "en".to_owned(),
|
||||
created_at: now,
|
||||
consumed_at: None,
|
||||
};
|
||||
|
||||
vec![Self { session }]
|
||||
}
|
||||
}
|
||||
|
||||
/// Fields of the account recovery finish form
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
@@ -46,12 +46,12 @@ pub use self::{
|
||||
DeviceLinkFormField, EmailAddContext, EmailRecoveryContext, EmailVerificationContext,
|
||||
EmailVerificationPageContext, EmptyContext, ErrorContext, FormPostContext, IndexContext,
|
||||
LoginContext, LoginFormField, NotFoundContext, PolicyViolationContext, PostAuthContext,
|
||||
PostAuthContextInner, ReauthContext, ReauthFormField, RecoveryFinishContext,
|
||||
RecoveryFinishFormField, RecoveryProgressContext, RecoveryStartContext,
|
||||
RecoveryStartFormField, RegisterContext, RegisterFormField, SiteBranding, SiteConfigExt,
|
||||
SiteFeatures, TemplateContext, UpstreamExistingLinkContext, UpstreamRegister,
|
||||
UpstreamRegisterFormField, UpstreamSuggestLink, WithCaptcha, WithCsrf, WithLanguage,
|
||||
WithOptionalSession, WithSession,
|
||||
PostAuthContextInner, ReauthContext, ReauthFormField, RecoveryExpiredContext,
|
||||
RecoveryFinishContext, RecoveryFinishFormField, RecoveryProgressContext,
|
||||
RecoveryStartContext, RecoveryStartFormField, RegisterContext, RegisterFormField,
|
||||
SiteBranding, SiteConfigExt, SiteFeatures, TemplateContext, UpstreamExistingLinkContext,
|
||||
UpstreamRegister, UpstreamRegisterFormField, UpstreamSuggestLink, WithCaptcha, WithCsrf,
|
||||
WithLanguage, WithOptionalSession, WithSession,
|
||||
},
|
||||
forms::{FieldError, FormError, FormField, FormState, ToFormState},
|
||||
};
|
||||
@@ -357,6 +357,9 @@ register_templates! {
|
||||
/// Render the account recovery finish page
|
||||
pub fn render_recovery_finish(WithLanguage<WithCsrf<RecoveryFinishContext>>) { "pages/recovery/finish.html" }
|
||||
|
||||
/// Render the account recovery link expired page
|
||||
pub fn render_recovery_expired(WithLanguage<WithCsrf<RecoveryExpiredContext>>) { "pages/recovery/expired.html" }
|
||||
|
||||
/// Render the account recovery disabled page
|
||||
pub fn render_recovery_disabled(WithLanguage<EmptyContext>) { "pages/recovery/disabled.html" }
|
||||
|
||||
@@ -428,6 +431,7 @@ impl Templates {
|
||||
check::render_recovery_start(self, now, rng)?;
|
||||
check::render_recovery_progress(self, now, rng)?;
|
||||
check::render_recovery_finish(self, now, rng)?;
|
||||
check::render_recovery_expired(self, now, rng)?;
|
||||
check::render_recovery_disabled(self, now, rng)?;
|
||||
check::render_reauth(self, now, rng)?;
|
||||
check::render_form_post::<EmptyContext>(self, now, rng)?;
|
||||
|
Reference in New Issue
Block a user