From eadb850009d0bfa68755645cc54241990b722dea Mon Sep 17 00:00:00 2001 From: Timshel Date: Thu, 16 Nov 2023 12:52:10 +0100 Subject: [PATCH] Review fixes --- src/api/core/accounts.rs | 2 +- src/api/core/organizations.rs | 8 ++++---- src/api/identity.rs | 12 +++++------- src/static/templates/email/send_org_invite.hbs | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index 69062a13b4..bd328b95a5 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -91,7 +91,7 @@ pub struct SetPasswordData { MasterPasswordHash: String, MasterPasswordHint: Option, #[allow(dead_code)] - orgIdentifier: Option, + OrgIdentifier: Option, } #[derive(Deserialize, Debug)] diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index b69c04b0b5..28fe414bcb 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -308,7 +308,7 @@ async fn get_user_collections(headers: Headers, mut conn: DbConn) -> Json // Called during the SSO enrollement #[get("/organizations/<_identifier>/auto-enroll-status")] -fn get_auto_enroll_status(_identifier: String) -> JsonResult { +fn get_auto_enroll_status(_identifier: &str) -> JsonResult { Ok(Json(json!({ "ResetPasswordEnabled": false, // Not implemented }))) @@ -1686,14 +1686,14 @@ async fn list_policies_token(org_id: &str, token: &str, mut conn: DbConn) -> Jso // Since the VW SSO flow is not linked to an organization it will be called with a dummy or undefinned `org_id` #[allow(non_snake_case)] #[get("/organizations//policies/invited-user?")] -async fn list_policies_invited_user(org_id: String, userId: String, mut conn: DbConn) -> JsonResult { +async fn list_policies_invited_user(org_id: &str, userId: &str, mut conn: DbConn) -> JsonResult { if userId.is_empty() { err!("userId must not be empty"); } - let user_orgs = UserOrganization::find_invited_by_user(&userId, &mut conn).await; + let user_orgs = UserOrganization::find_invited_by_user(userId, &mut conn).await; let policies_json: Vec = if user_orgs.into_iter().any(|user_org| user_org.org_uuid == org_id) { - let policies = OrgPolicy::find_by_org(&org_id, &mut conn).await; + let policies = OrgPolicy::find_by_org(org_id, &mut conn).await; policies.iter().map(OrgPolicy::to_json).collect() } else { vec![] diff --git a/src/api/identity.rs b/src/api/identity.rs index 73ebfde5e6..2cad4b9b2f 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -376,7 +376,7 @@ async fn authenticated_response( "KdfIterations": user.client_kdf_iter, "KdfMemory": user.client_kdf_memory, "KdfParallelism": user.client_kdf_parallelism, - "ResetMasterPassword": user.password_hash.is_empty(), + "ResetMasterPassword": false,// TODO: Same as above "scope": scope, "unofficialServer": true, "UserDecryptionOptions": { @@ -782,17 +782,16 @@ fn _check_is_some(value: &Option, msg: &str) -> EmptyResult { } #[get("/account/prevalidate")] -#[allow(non_snake_case)] fn prevalidate() -> JsonResult { let claims = generate_ssotoken_claims(); - let ssotoken = encode_jwt(&claims); + let sso_token = encode_jwt(&claims); Ok(Json(json!({ - "token": ssotoken, + "token": sso_token, }))) } #[get("/connect/oidc-signin?")] -fn oidcsignin(code: String, jar: &CookieJar<'_>, _conn: DbConn) -> ApiResult { +fn oidcsignin(code: String, jar: &CookieJar<'_>) -> ApiResult { let cookiemanager = CookieManager::new(jar); let redirect_uri = cookiemanager .get_cookie("redirect_uri".to_string()) @@ -815,7 +814,6 @@ fn oidcsignin(code: String, jar: &CookieJar<'_>, _conn: DbConn) -> ApiResult, #[allow(unused)] #[field(name = uncased("ssoToken"))] - ssoToken: Option, + sso_token: Option, } #[get("/connect/authorize?")] diff --git a/src/static/templates/email/send_org_invite.hbs b/src/static/templates/email/send_org_invite.hbs index c4535b736d..be94d0e540 100644 --- a/src/static/templates/email/send_org_invite.hbs +++ b/src/static/templates/email/send_org_invite.hbs @@ -7,4 +7,4 @@ Click here to join: {{url}}/#/accept-organization/?organizationId={{org_id}}&org If you do not wish to join this organization, you can safely ignore this email. -{{> email/email_footer_text }} +{{> email/email_footer_text }} \ No newline at end of file