Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2025-01-31 10:08:56 +01:00
Review fixes
Dieser Commit ist enthalten in:
Ursprung
6f9b88e572
Commit
0b556b21b0
3 geänderte Dateien mit 9 neuen und 13 gelöschten Zeilen
|
@ -177,7 +177,7 @@ pub async fn _register(data: Json<RegisterData>, mut conn: DbConn) -> JsonResult
|
||||||
err!("Registration email does not match invite email")
|
err!("Registration email does not match invite email")
|
||||||
}
|
}
|
||||||
} else if Invitation::take(&email, &mut conn).await {
|
} else if Invitation::take(&email, &mut conn).await {
|
||||||
Membership::confirm_user_invitations(&user.uuid, &mut conn).await?;
|
Membership::accept_user_invitations(&user.uuid, &mut conn).await?;
|
||||||
user
|
user
|
||||||
} else if CONFIG.is_signup_allowed(&email)
|
} else if CONFIG.is_signup_allowed(&email)
|
||||||
|| (CONFIG.emergency_access_allowed()
|
|| (CONFIG.emergency_access_allowed()
|
||||||
|
@ -298,7 +298,7 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, mut co
|
||||||
if CONFIG.mail_enabled() {
|
if CONFIG.mail_enabled() {
|
||||||
mail::send_set_password(&user.email.to_lowercase(), &user.name).await?;
|
mail::send_set_password(&user.email.to_lowercase(), &user.name).await?;
|
||||||
} else {
|
} else {
|
||||||
Membership::confirm_user_invitations(&user.uuid, &mut conn).await?;
|
Membership::accept_user_invitations(&user.uuid, &mut conn).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.save(&mut conn).await?;
|
user.save(&mut conn).await?;
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
||||||
auth::{decode_invite, AdminHeaders, ClientVersion, Headers, ManagerHeaders, ManagerHeadersLoose, OwnerHeaders},
|
auth::{decode_invite, AdminHeaders, ClientVersion, Headers, ManagerHeaders, ManagerHeadersLoose, OwnerHeaders},
|
||||||
db::{models::*, DbConn},
|
db::{models::*, DbConn},
|
||||||
mail,
|
mail,
|
||||||
util::{convert_json_key_lcase_first, NumberOrString},
|
util::{convert_json_key_lcase_first, get_uuid, NumberOrString},
|
||||||
CONFIG,
|
CONFIG,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ async fn get_user_collections(headers: Headers, mut conn: DbConn) -> Json<Value>
|
||||||
#[get("/organizations/<_identifier>/auto-enroll-status")]
|
#[get("/organizations/<_identifier>/auto-enroll-status")]
|
||||||
fn get_auto_enroll_status(_identifier: &str) -> JsonResult {
|
fn get_auto_enroll_status(_identifier: &str) -> JsonResult {
|
||||||
Ok(Json(json!({
|
Ok(Json(json!({
|
||||||
"Id": "_",
|
"Id": get_uuid(),
|
||||||
"ResetPasswordEnabled": false, // Not implemented
|
"ResetPasswordEnabled": false, // Not implemented
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
@ -1882,18 +1882,14 @@ async fn list_policies_token(org_id: OrganizationId, token: &str, mut conn: DbCo
|
||||||
// Called during the SSO enrollment.
|
// Called during the SSO enrollment.
|
||||||
// Cannot use the OrganizationId guard since the Org does not exists.
|
// Cannot use the OrganizationId guard since the Org does not exists.
|
||||||
#[get("/organizations/<org_id>/policies/master-password", rank = 1)]
|
#[get("/organizations/<org_id>/policies/master-password", rank = 1)]
|
||||||
fn get_master_password_policy(org_id: &str, _headers: Headers) -> JsonResult {
|
fn get_master_password_policy(org_id: OrganizationId, _headers: Headers) -> JsonResult {
|
||||||
let data = match CONFIG.sso_master_password_policy() {
|
let data = match CONFIG.sso_master_password_policy() {
|
||||||
Some(policy) => policy,
|
Some(policy) => policy,
|
||||||
None => "null".to_string(),
|
None => "null".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let policy = OrgPolicy::new(
|
let policy =
|
||||||
OrganizationId(org_id.to_string()),
|
OrgPolicy::new(org_id, OrgPolicyType::MasterPassword, CONFIG.sso_master_password_policy().is_some(), data);
|
||||||
OrgPolicyType::MasterPassword,
|
|
||||||
CONFIG.sso_master_password_policy().is_some(),
|
|
||||||
data,
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(policy.to_json()))
|
Ok(Json(policy.to_json()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,7 +807,7 @@ impl Membership {
|
||||||
|
|
||||||
// Should be used only when email are disabled.
|
// Should be used only when email are disabled.
|
||||||
// In Organizations::send_invite status is set to Accepted only if the user has a password.
|
// In Organizations::send_invite status is set to Accepted only if the user has a password.
|
||||||
pub async fn confirm_user_invitations(user_uuid: &UserId, conn: &mut DbConn) -> EmptyResult {
|
pub async fn accept_user_invitations(user_uuid: &UserId, conn: &mut DbConn) -> EmptyResult {
|
||||||
db_run! { conn: {
|
db_run! { conn: {
|
||||||
diesel::update(users_organizations::table)
|
diesel::update(users_organizations::table)
|
||||||
.filter(users_organizations::user_uuid.eq(user_uuid))
|
.filter(users_organizations::user_uuid.eq(user_uuid))
|
||||||
|
@ -1151,7 +1151,7 @@ impl OrganizationApiKey {
|
||||||
)]
|
)]
|
||||||
#[deref(forward)]
|
#[deref(forward)]
|
||||||
#[from(forward)]
|
#[from(forward)]
|
||||||
pub struct OrganizationId(pub String);
|
pub struct OrganizationId(String);
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren