code review : syntax

This commit is contained in:
aDeve 2018-11-07 19:29:37 +01:00
parent d07edb0c5b
commit 0674002553
2 changed files with 7 additions and 2 deletions

View File

@ -60,10 +60,14 @@ export class AuthPage extends React.Component { // eslint-disable-line react/pre
this.setForm();
hideLoginErrorsInput(false);
}
if (submitSuccess && submitSuccess !== prevProps.submitSuccess) {
if (submitSuccess) {
switch (authType) {
case 'login':
case 'reset-password':
// Check if we have token to handle redirection to login or admin.
// Done to prevent redirection to admin after reset password if user should
// not have access.
auth.getToken()
? this.redirect('/')
: this.redirect('/plugins/users-permissions/auth/login');
@ -135,7 +139,7 @@ export class AuthPage extends React.Component { // eslint-disable-line react/pre
}
}
redirect = path => this.props.history.push(path)
redirect = path => this.props.history.push(path);
renderButton = () => {
const { match: { params: { authType } }, submitSuccess } = this.props;

View File

@ -37,6 +37,7 @@ export function* submitForm(action) {
const response = yield call(request, requestURL, { method: 'POST', body: omit(body, 'news') });
if(get(response, 'user.role.name', '') === 'Administrator' || isRegister){
yield call(auth.setToken, response.jwt, body.rememberMe);
yield call(auth.setUserInfo, response.user, body.rememberMe);
}