mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 14:35:45 +01:00
Use HATEOAS link to change password
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
// @flow
|
||||
|
||||
import type { Links } from "./hal";
|
||||
|
||||
export type Me = {
|
||||
name: string,
|
||||
displayName: string,
|
||||
mail: string
|
||||
mail: string,
|
||||
_links: Links
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import type { User } from "../../../scm-ui-components/packages/ui-types/src/index";
|
||||
import {
|
||||
SubmitButton,
|
||||
Notification,
|
||||
@@ -8,11 +7,12 @@ import {
|
||||
InputField
|
||||
} from "../../../scm-ui-components/packages/ui-components/src/index";
|
||||
import { translate } from "react-i18next";
|
||||
import { setPassword, updatePassword } from "../users/components/changePassword";
|
||||
import { updatePassword } from "../users/components/changePassword";
|
||||
import PasswordConfirmation from "../users/components/PasswordConfirmation";
|
||||
import type { Me } from "@scm-manager/ui-types";
|
||||
|
||||
type Props = {
|
||||
user: User,
|
||||
me: Me,
|
||||
t: string => string
|
||||
};
|
||||
|
||||
@@ -69,11 +69,7 @@ class ChangeUserPassword extends React.Component<Props, State> {
|
||||
if (this.state.password) {
|
||||
const { oldPassword, password } = this.state;
|
||||
this.setLoadingState();
|
||||
updatePassword(
|
||||
"http://localhost:8081/scm/api/v2/me/password", // TODO: Change this, as soon we have a profile component
|
||||
oldPassword,
|
||||
password
|
||||
)
|
||||
updatePassword(this.props.me._links.password.href, oldPassword, password)
|
||||
.then(result => {
|
||||
if (result.error) {
|
||||
this.setErrorState(result.error);
|
||||
|
||||
@@ -60,8 +60,7 @@ class Profile extends React.Component<Props, State> {
|
||||
<Route path={url} exact render={() => <ProfileInfo me={me} />} />
|
||||
<Route
|
||||
path={`${url}/password`}
|
||||
exact
|
||||
component={ChangeUserPassword}
|
||||
render={() => <ChangeUserPassword me={me} />}
|
||||
/>
|
||||
</div>
|
||||
<div className="column">
|
||||
|
||||
@@ -136,10 +136,12 @@ const callFetchMe = (link: string): Promise<Me> => {
|
||||
return response.json();
|
||||
})
|
||||
.then(json => {
|
||||
const { name, displayName, mail, _links } = json;
|
||||
return {
|
||||
name: json.name,
|
||||
displayName: json.displayName,
|
||||
mail: json.mail
|
||||
name,
|
||||
displayName,
|
||||
mail,
|
||||
_links
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -14,7 +14,6 @@ type State = {
|
||||
};
|
||||
type Props = {
|
||||
passwordChanged: string => void,
|
||||
password: string,
|
||||
// Context props
|
||||
t: string => string
|
||||
};
|
||||
|
||||
@@ -79,7 +79,6 @@ class SetUserPassword extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
console.log("RENDER");
|
||||
const { t } = this.props;
|
||||
const { loading, passwordChanged, error } = this.state;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user