From 5827a18866a5df7a359b258bdde26ebc6d453447 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 2 Mar 2024 16:50:39 +0100 Subject: [PATCH] Remove old-password form on reset-pasword menu if user does not have one --- .../Models/Resources/User.cs | 3 +++ front/packages/models/src/resources/user.ts | 4 ++++ front/packages/ui/src/settings/account.tsx | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/back/src/Kyoo.Abstractions/Models/Resources/User.cs b/back/src/Kyoo.Abstractions/Models/Resources/User.cs index 3ee69773..2f049b7f 100644 --- a/back/src/Kyoo.Abstractions/Models/Resources/User.cs +++ b/back/src/Kyoo.Abstractions/Models/Resources/User.cs @@ -56,6 +56,9 @@ namespace Kyoo.Abstractions.Models [SerializeIgnore] public string? Password { get; set; } + /// + /// Does the user can sign-in with a password or only via oidc? + /// public bool HasPassword => Password != null; /// diff --git a/front/packages/models/src/resources/user.ts b/front/packages/models/src/resources/user.ts index eaa56067..0b47d830 100644 --- a/front/packages/models/src/resources/user.ts +++ b/front/packages/models/src/resources/user.ts @@ -36,6 +36,10 @@ export const UserP = ResourceP("user") * The list of permissions of the user. The format of this is implementation dependent. */ permissions: z.array(z.string()), + /** + * Does the user can sign-in with a password or only via oidc? + */ + hasPassword: z.boolean().default(true), /** * User settings */ diff --git a/front/packages/ui/src/settings/account.tsx b/front/packages/ui/src/settings/account.tsx index ae79972f..237f259b 100644 --- a/front/packages/ui/src/settings/account.tsx +++ b/front/packages/ui/src/settings/account.tsx @@ -197,6 +197,7 @@ export const AccountSettings = () => { await editPassword({ oldPassword: op, newPassword: np })} close={close} />, @@ -264,11 +265,13 @@ const ChangePopup = ({ const ChangePasswordPopup = ({ label, icon, + hasPassword, apply, close, }: { label: string; icon: Icon; + hasPassword: boolean; apply: (oldPassword: string, newPassword: string) => Promise; close: () => void; }) => { @@ -285,13 +288,15 @@ const ChangePasswordPopup = ({

{label}

- setOldValue(v)} - placeholder={t("settings.account.password.oldPassword")} - /> + {hasPassword && ( + setOldValue(v)} + placeholder={t("settings.account.password.oldPassword")} + /> + )}