mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 13:16:56 +00:00
fix: Properly show email in account page when OIDC email_claim is set
This commit is contained in:
4 files changed
+19
-4
No files matched your search
@@ -25,6 +25,10 @@ pub(crate) async fn third_party_route(
|
|||||||
let sender_user = body.identity.expect_sender_user()?;
|
let sender_user = body.identity.expect_sender_user()?;
|
||||||
let mut threepids = vec![];
|
let mut threepids = vec![];
|
||||||
|
|
||||||
|
if !services.threepid.email_requirement().may_view() {
|
||||||
|
return Ok(get_3pids::v3::Response::new(vec![]));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(email) = services
|
if let Some(email) = services
|
||||||
.threepid
|
.threepid
|
||||||
.get_email_for_localpart(sender_user.localpart())
|
.get_email_for_localpart(sender_user.localpart())
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ pub enum EmailRequirement {
|
|||||||
Required,
|
Required,
|
||||||
/// Users may change or remove their email.
|
/// Users may change or remove their email.
|
||||||
Optional,
|
Optional,
|
||||||
/// Users may not change their email at all.
|
/// Users may see their email, but may not change it.
|
||||||
|
Locked,
|
||||||
|
/// Email features are disabled.
|
||||||
Unavailable,
|
Unavailable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +45,9 @@ impl EmailRequirement {
|
|||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn may_remove(&self) -> bool { matches!(self, Self::Optional) }
|
pub fn may_remove(&self) -> bool { matches!(self, Self::Optional) }
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn may_view(&self) -> bool { !matches!(self, Self::Unavailable) }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Data {
|
struct Data {
|
||||||
@@ -91,7 +96,7 @@ impl Service {
|
|||||||
&& matches!(oidc.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
&& matches!(oidc.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
||||||
&& oidc.email_claim.is_some()
|
&& oidc.email_claim.is_some()
|
||||||
{
|
{
|
||||||
EmailRequirement::Unavailable
|
EmailRequirement::Locked
|
||||||
} else if smtp.require_email_for_registration
|
} else if smtp.require_email_for_registration
|
||||||
|| smtp.require_email_for_token_registration
|
|| smtp.require_email_for_token_registration
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ async fn route_change_email(
|
|||||||
) -> Result {
|
) -> Result {
|
||||||
let user_id = user.expect_recent(LoginTarget::ChangeEmail)?;
|
let user_id = user.expect_recent(LoginTarget::ChangeEmail)?;
|
||||||
|
|
||||||
|
if !services.threepid.email_requirement().may_change() {
|
||||||
|
return Err(WebError::Forbidden("You may not change your email address.".to_owned()));
|
||||||
|
}
|
||||||
|
|
||||||
let Some(form) = form else {
|
let Some(form) = form else {
|
||||||
return response!(ChangeEmail::new(
|
return response!(ChangeEmail::new(
|
||||||
context.clone(),
|
context.clone(),
|
||||||
|
|||||||
@@ -17,14 +17,16 @@ Your account
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<section>
|
<section>
|
||||||
{% if email_requirement.may_change() %}
|
{% if email_requirement.may_view() %}
|
||||||
<p>
|
<p>
|
||||||
{% if let Some(email) = email %}
|
{% if let Some(email) = email %}
|
||||||
Your account's associated email address is <code>{{ email }}</code>.
|
Your account's associated email address is <code>{{ email }}</code>.
|
||||||
{% else %}
|
{% else %}
|
||||||
Your account has no associated email address.
|
Your account has no associated email address.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="email/change/">Change your email</a>
|
{% if email_requirement.may_change() %}
|
||||||
|
<a href="email/change/">Change your email</a>\
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if !oidc_enabled %}
|
{% if !oidc_enabled %}
|
||||||
|
|||||||
Reference in new issue
Block a user