@@ -313,7 +313,7 @@ pub struct ClaimsImports {
313
313
pub subject : SubjectPreference ,
314
314
315
315
#[ serde( default ) ]
316
- pub localpart : ImportPreference ,
316
+ pub localpart : LocalpartPreference ,
317
317
318
318
#[ serde( default ) ]
319
319
pub displayname : ImportPreference ,
@@ -332,6 +332,26 @@ pub struct SubjectPreference {
332
332
pub template : Option < String > ,
333
333
}
334
334
335
+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , Default ) ]
336
+ pub struct LocalpartPreference {
337
+ #[ serde( default ) ]
338
+ pub action : ImportAction ,
339
+
340
+ #[ serde( default ) ]
341
+ pub template : Option < String > ,
342
+
343
+ #[ serde( default ) ]
344
+ pub on_conflict : OnConflict ,
345
+ }
346
+
347
+ impl std:: ops:: Deref for LocalpartPreference {
348
+ type Target = ImportAction ;
349
+
350
+ fn deref ( & self ) -> & Self :: Target {
351
+ & self . action
352
+ }
353
+ }
354
+
335
355
#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , Default ) ]
336
356
pub struct ImportPreference {
337
357
#[ serde( default ) ]
@@ -368,7 +388,7 @@ pub enum ImportAction {
368
388
369
389
impl ImportAction {
370
390
#[ must_use]
371
- pub fn is_forced ( & self ) -> bool {
391
+ pub fn is_forced_or_required ( & self ) -> bool {
372
392
matches ! ( self , Self :: Force | Self :: Require )
373
393
}
374
394
@@ -391,3 +411,15 @@ impl ImportAction {
391
411
}
392
412
}
393
413
}
414
+
415
+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , Default ) ]
416
+ #[ serde( rename_all = "lowercase" ) ]
417
+ pub enum OnConflict {
418
+ /// Fails the upstream OAuth 2.0 login
419
+ #[ default]
420
+ Fail ,
421
+
422
+ /// Adds the upstream account link, regardless of whether there is an
423
+ /// existing link or not
424
+ Add ,
425
+ }
0 commit comments