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