Remove old-password form on reset-pasword menu if user does not have one

This commit is contained in:
Zoe Roux 2024-03-02 16:50:39 +01:00
parent 633db89031
commit 5827a18866
3 changed files with 19 additions and 7 deletions

View File

@ -56,6 +56,9 @@ namespace Kyoo.Abstractions.Models
[SerializeIgnore]
public string? Password { get; set; }
/// <summary>
/// Does the user can sign-in with a password or only via oidc?
/// </summary>
public bool HasPassword => Password != null;
/// <summary>

View File

@ -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
*/

View File

@ -197,6 +197,7 @@ export const AccountSettings = () => {
<ChangePasswordPopup
icon={Password}
label={t("settings.account.password.label")}
hasPassword={account.hasPassword}
apply={async (op, np) => 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<unknown>;
close: () => void;
}) => {
@ -285,13 +288,15 @@ const ChangePasswordPopup = ({
<Icon icon={icon} />
<H1 {...css({ fontSize: rem(2) })}>{label}</H1>
</View>
<PasswordInput
autoComplete="current-password"
variant="big"
value={oldValue}
onChangeText={(v) => setOldValue(v)}
placeholder={t("settings.account.password.oldPassword")}
/>
{hasPassword && (
<PasswordInput
autoComplete="current-password"
variant="big"
value={oldValue}
onChangeText={(v) => setOldValue(v)}
placeholder={t("settings.account.password.oldPassword")}
/>
)}
<PasswordInput
autoComplete="password-new"
variant="big"