Add resetPassword action
This commit is contained in:
parent
7e0dec594f
commit
a2e19e3720
|
@ -11,6 +11,10 @@ export const AUTH_REGISTER_REQUEST = 'AUTH_REGISTER_REQUEST';
|
||||||
export const AUTH_REGISTER_SUCCESS = 'AUTH_REGISTER_SUCCESS';
|
export const AUTH_REGISTER_SUCCESS = 'AUTH_REGISTER_SUCCESS';
|
||||||
export const AUTH_REGISTER_FAIL = 'AUTH_REGISTER_FAIL';
|
export const AUTH_REGISTER_FAIL = 'AUTH_REGISTER_FAIL';
|
||||||
|
|
||||||
|
export const RESET_PASSWORD_REQUEST = 'RESET_PASSWORD_REQUEST';
|
||||||
|
export const RESET_PASSWORD_SUCCESS = 'RESET_PASSWORD_SUCCESS';
|
||||||
|
export const RESET_PASSWORD_FAIL = 'RESET_PASSWORD_FAIL';
|
||||||
|
|
||||||
const hasAppToken = getState => getState().hasIn(['auth', 'app', 'access_token']);
|
const hasAppToken = getState => getState().hasIn(['auth', 'app', 'access_token']);
|
||||||
const noOp = () => () => new Promise(f => f());
|
const noOp = () => () => new Promise(f => f());
|
||||||
|
|
||||||
|
@ -148,6 +152,21 @@ export function fetchCaptcha() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resetPassword(nickNameOrEmail) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({ type: RESET_PASSWORD_REQUEST });
|
||||||
|
const params =
|
||||||
|
nickNameOrEmail.includes('@')
|
||||||
|
? { email: nickNameOrEmail }
|
||||||
|
: { nickname: nickNameOrEmail };
|
||||||
|
return api(getState).post('/auth/password', params).then(() => {
|
||||||
|
dispatch({ type: RESET_PASSWORD_SUCCESS });
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch({ type: RESET_PASSWORD_FAIL });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function authAppCreated(app) {
|
export function authAppCreated(app) {
|
||||||
return {
|
return {
|
||||||
type: AUTH_APP_CREATED,
|
type: AUTH_APP_CREATED,
|
||||||
|
|
Loading…
Reference in New Issue