Skip to content

Commit

Permalink
Force registration in OIDC handler (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra authored Oct 29, 2023
1 parent 009a361 commit f34ec9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/kitsune-core/src/service/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ pub struct Register {
#[builder(default)]
#[garde(skip)]
captcha_token: Option<String>,

/// Force the registration to succeed, regardless of closed registrations
#[builder(setter(strip_bool))]
#[garde(skip)]
force_registration: bool,
}

#[derive(Clone, TypedBuilder)]
Expand Down Expand Up @@ -137,7 +142,7 @@ impl UserService {
}

pub async fn register(&self, register: Register) -> Result<User> {
if !self.registrations_open {
if !self.registrations_open && !register.force_registration {
return Err(ApiError::RegistrationsClosed.into());
}

Expand Down
1 change: 1 addition & 0 deletions kitsune/src/http/handler/oidc/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub async fn get(
user
} else {
let register = Register::builder()
.force_registration()
.email(user_info.email)
.username(user_info.username)
.oidc_id(user_info.subject)
Expand Down

0 comments on commit f34ec9d

Please sign in to comment.