confirm password modal by enter key / fix password link for logged in user

This commit is contained in:
Eduard Heimbuch
2020-10-30 11:48:05 +01:00
parent 6d0881d3d9
commit 0c8fe5a60c
3 changed files with 13 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ type State = {
type Props = WithTranslation & {
passwordChanged: (p1: string, p2: boolean) => void;
passwordValidator?: (p: string) => boolean;
onReturnPressed?: () => void;
};
class PasswordConfirmation extends React.Component<Props, State> {
@@ -57,7 +58,7 @@ class PasswordConfirmation extends React.Component<Props, State> {
}
render() {
const { t } = this.props;
const { t, onReturnPressed } = this.props;
return (
<div className="columns is-multiline">
<div className="column is-half">
@@ -78,6 +79,7 @@ class PasswordConfirmation extends React.Component<Props, State> {
value={this.state ? this.state.confirmedPassword : ""}
validationError={this.state.passwordConfirmationFailed}
errorMessage={t("password.passwordConfirmFailed")}
onReturnPressed={onReturnPressed}
/>
</div>
</div>

View File

@@ -94,7 +94,15 @@ const UserConverter: FC<Props> = ({ user, fetchUser }) => {
}
};
const passwordChangeField = <PasswordConfirmation passwordChanged={changePassword} />;
const onReturnPressed = () => {
if (password && passwordValid) {
toInternal();
}
};
const passwordChangeField = (
<PasswordConfirmation passwordChanged={changePassword} onReturnPressed={onReturnPressed} />
);
const passwordModal = (
<Modal
body={passwordChangeField}

View File

@@ -102,7 +102,7 @@ public class MeDtoFactory extends HalAppenderMapper {
if (UserPermissions.changePublicKeys(user).isPermitted()) {
linksBuilder.single(link("publicKeys", resourceLinks.user().publicKeys(user.getName())));
}
if (userManager.isTypeDefault(user) && UserPermissions.changePassword(user).isPermitted()) {
if (!user.isExternal() && UserPermissions.changePassword(user).isPermitted()) {
linksBuilder.single(link("password", resourceLinks.me().passwordChange()));
}
if (UserPermissions.changeApiKeys(user).isPermitted()) {