Skip to content

Commit 21dae3c

Browse files
committed
update graphql, translation and correct clippy
1 parent 8774339 commit 21dae3c

File tree

5 files changed

+2527
-35
lines changed

5 files changed

+2527
-35
lines changed

crates/config/src/sections/upstream_oauth2.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ impl ConfigurationSection for UpstreamOAuth2Config {
112112
}
113113

114114
if provider.claims_imports.localpart.on_conflict.is_some()
115-
&& !provider.claims_imports.localpart.on_conflict.unwrap().is_fail()
115+
&& !provider
116+
.claims_imports
117+
.localpart
118+
.on_conflict
119+
.unwrap()
120+
.is_fail()
116121
&& !matches!(
117122
provider.claims_imports.localpart.action,
118123
ImportAction::Force | ImportAction::Require
@@ -212,8 +217,8 @@ pub enum OnConflict {
212217
}
213218

214219
impl OnConflict {
215-
const fn is_fail(&self) -> bool {
216-
matches!(self, OnConflict::Fail)
220+
const fn is_fail(self) -> bool {
221+
matches!(&self, OnConflict::Fail)
217222
}
218223
}
219224

@@ -246,7 +251,7 @@ pub struct LocalpartImportPreference {
246251
#[serde(default, skip_serializing_if = "Option::is_none")]
247252
pub template: Option<String>,
248253

249-
/// How to handle conflicts on the claim, default value is `Fail``
254+
/// How to handle conflicts on the claim, default value is `Fail`
250255
#[serde(default, skip_serializing_if = "Option::is_none")]
251256
pub on_conflict: Option<OnConflict>,
252257
}

crates/handlers/src/upstream_oauth2/link.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ pub(crate) async fn get(
516516
let ctx = ErrorContext::new()
517517
.with_code("Localpart not available")
518518
.with_description(format!(
519-
r"Localpart is not available on this homeserver"
519+
r"Localpart {localpart:?} is not available on this homeserver"
520520
))
521521
.with_language(&locale);
522522

@@ -652,19 +652,20 @@ pub(crate) async fn post(
652652
(None, None, FormData::Link) => {
653653
// User already exists, but it is not linked, neither logged in
654654
// Proceed by associating the link to the user and log in the user
655-
// Upstream_session is used to re-render the username as it is the only source of truth
656-
655+
// Upstream_session is used to re-render the username as it is the only source
656+
// of truth
657+
657658
let id_token = upstream_session.id_token().map(Jwt::try_from).transpose()?;
658659

659660
let provider = repo
660661
.upstream_oauth_provider()
661662
.lookup(link.provider_id)
662663
.await?
663664
.ok_or(RouteError::ProviderNotFound(link.provider_id))?;
664-
665+
665666
// Let's import the username from the localpart claim
666667
let env = environment();
667-
668+
668669
let mut context = AttributeMappingContext::new();
669670
if let Some(id_token) = id_token {
670671
let (_, payload) = id_token.into_parts();
@@ -677,18 +678,17 @@ pub(crate) async fn post(
677678
context = context.with_userinfo_claims(userinfo.clone());
678679
}
679680
let context = context.build();
680-
681-
681+
682682
//Claims import must be `require` or `force` at this stage
683683
let template = provider
684684
.claims_imports
685685
.localpart
686686
.template
687687
.as_deref()
688688
.unwrap_or(DEFAULT_LOCALPART_TEMPLATE);
689-
690-
let username = render_attribute_template(&env, template, &context, true)?;
691-
689+
690+
let username = render_attribute_template(&env, template, &context, true)?;
691+
692692
let maybe_user = repo.user().find_by_username(&username.unwrap()).await?;
693693

694694
if maybe_user.is_some() {

docs/config.schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,7 +2345,7 @@
23452345
"type": "string"
23462346
},
23472347
"on_conflict": {
2348-
"description": "How to handle existing users (only for localpart)",
2348+
"description": "How to handle conflicts on the claim, default value is `Fail`",
23492349
"allOf": [
23502350
{
23512351
"$ref": "#/definitions/OnConflict"
@@ -2388,17 +2388,17 @@
23882388
]
23892389
},
23902390
"OnConflict": {
2391-
"description": "How to handle when localpart already exists",
2391+
"description": "How to handle an existing localpart claim",
23922392
"oneOf": [
23932393
{
2394-
"description": "Fails the sso login on localpart conflict",
2394+
"description": "Fails the sso login on conflict",
23952395
"type": "string",
23962396
"enum": [
23972397
"fail"
23982398
]
23992399
},
24002400
{
2401-
"description": "Adds the oauth identity link to the existing user, regardless of whether there is an existing link or not",
2401+
"description": "Adds the oauth identity link, regardless of whether there is an existing link or not",
24022402
"type": "string",
24032403
"enum": [
24042404
"add"

0 commit comments

Comments
 (0)