diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index ec2f30b6..fef3323c 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -177,7 +177,7 @@ pub async fn _register(data: Json, mut conn: DbConn) -> JsonResult err!("Registration email does not match invite email") } } 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 } else if CONFIG.is_signup_allowed(&email) || (CONFIG.emergency_access_allowed() @@ -298,7 +298,7 @@ async fn post_set_password(data: Json, headers: Headers, mut co if CONFIG.mail_enabled() { mail::send_set_password(&user.email.to_lowercase(), &user.name).await?; } else { - Membership::confirm_user_invitations(&user.uuid, &mut conn).await?; + Membership::accept_user_invitations(&user.uuid, &mut conn).await?; } user.save(&mut conn).await?; diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 6d8732d9..8486d669 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -12,7 +12,7 @@ use crate::{ auth::{decode_invite, AdminHeaders, ClientVersion, Headers, ManagerHeaders, ManagerHeadersLoose, OwnerHeaders}, db::{models::*, DbConn}, mail, - util::{convert_json_key_lcase_first, NumberOrString}, + util::{convert_json_key_lcase_first, get_uuid, NumberOrString}, CONFIG, }; @@ -330,7 +330,7 @@ async fn get_user_collections(headers: Headers, mut conn: DbConn) -> Json #[get("/organizations/<_identifier>/auto-enroll-status")] fn get_auto_enroll_status(_identifier: &str) -> JsonResult { Ok(Json(json!({ - "Id": "_", + "Id": get_uuid(), "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. // Cannot use the OrganizationId guard since the Org does not exists. #[get("/organizations//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() { Some(policy) => policy, None => "null".to_string(), }; - let policy = OrgPolicy::new( - OrganizationId(org_id.to_string()), - OrgPolicyType::MasterPassword, - CONFIG.sso_master_password_policy().is_some(), - data, - ); + let policy = + OrgPolicy::new(org_id, OrgPolicyType::MasterPassword, CONFIG.sso_master_password_policy().is_some(), data); Ok(Json(policy.to_json())) } diff --git a/src/db/models/organization.rs b/src/db/models/organization.rs index f9039aff..40a74995 100644 --- a/src/db/models/organization.rs +++ b/src/db/models/organization.rs @@ -807,7 +807,7 @@ impl Membership { // Should be used only when email are disabled. // 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: { diesel::update(users_organizations::table) .filter(users_organizations::user_uuid.eq(user_uuid)) @@ -1151,7 +1151,7 @@ impl OrganizationApiKey { )] #[deref(forward)] #[from(forward)] -pub struct OrganizationId(pub String); +pub struct OrganizationId(String); #[derive( Clone,