Browse Source

Use Org uuid as identifier

pull/6263/head
Timshel 3 weeks ago
parent
commit
2941f82532
  1. 2
      src/api/core/accounts.rs
  2. 14
      src/api/core/organizations.rs

2
src/api/core/accounts.rs

@ -367,7 +367,7 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, mut co
if let Some(identifier) = data.org_identifier { if let Some(identifier) = data.org_identifier {
if identifier != crate::sso::FAKE_IDENTIFIER { if identifier != crate::sso::FAKE_IDENTIFIER {
let org = match Organization::find_by_name(&identifier, &mut conn).await { let org = match Organization::find_by_uuid(&identifier.into(), &mut conn).await {
None => err!("Failed to retrieve the associated organization"), None => err!("Failed to retrieve the associated organization"),
Some(org) => org, Some(org) => org,
}; };

14
src/api/core/organizations.rs

@ -339,7 +339,7 @@ async fn get_user_collections(headers: Headers, mut conn: DbConn) -> Json<Value>
} }
// Called during the SSO enrollment // Called during the SSO enrollment
// The `identifier` should be the value returned by `get_org_domain_sso_details` // The `identifier` should be the value returned by `get_org_domain_sso_verified`
// The returned `Id` will then be passed to `get_master_password_policy` which will mainly ignore it // The returned `Id` will then be passed to `get_master_password_policy` which will mainly ignore it
#[get("/organizations/<identifier>/auto-enroll-status")] #[get("/organizations/<identifier>/auto-enroll-status")]
async fn get_auto_enroll_status(identifier: &str, headers: Headers, mut conn: DbConn) -> JsonResult { async fn get_auto_enroll_status(identifier: &str, headers: Headers, mut conn: DbConn) -> JsonResult {
@ -349,7 +349,7 @@ async fn get_auto_enroll_status(identifier: &str, headers: Headers, mut conn: Db
None => None, None => None,
} }
} else { } else {
Organization::find_by_name(identifier, &mut conn).await Organization::find_by_uuid(&identifier.into(), &mut conn).await
}; };
let (id, identifier, rp_auto_enroll) = match org { let (id, identifier, rp_auto_enroll) = match org {
@ -977,17 +977,17 @@ async fn get_org_domain_sso_verified(data: Json<OrgDomainDetails>, mut conn: DbC
let identifiers = match Organization::find_org_user_email(&data.email, &mut conn) let identifiers = match Organization::find_org_user_email(&data.email, &mut conn)
.await .await
.into_iter() .into_iter()
.map(|o| o.name) .map(|o| (o.name, o.uuid.to_string()))
.collect::<Vec<String>>() .collect::<Vec<(String, String)>>()
{ {
v if !v.is_empty() => v, v if !v.is_empty() => v,
_ => vec![crate::sso::FAKE_IDENTIFIER.to_string()], _ => vec![(crate::sso::FAKE_IDENTIFIER.to_string(), crate::sso::FAKE_IDENTIFIER.to_string())],
}; };
Ok(Json(json!({ Ok(Json(json!({
"object": "list", "object": "list",
"data": identifiers.into_iter().map(|identifier| json!({ "data": identifiers.into_iter().map(|(name, identifier)| json!({
"organizationName": identifier, // appear unused "organizationName": name, // appear unused
"organizationIdentifier": identifier, "organizationIdentifier": identifier,
"domainName": CONFIG.domain(), // appear unused "domainName": CONFIG.domain(), // appear unused
})).collect::<Vec<Value>>() })).collect::<Vec<Value>>()

Loading…
Cancel
Save