Init auth errors

This commit is contained in:
cyril lopez 2017-12-06 11:47:39 +01:00
parent 6da0cdcb6a
commit 642bee0085
5 changed files with 26 additions and 14 deletions

View File

@ -67,7 +67,8 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
}
if (!this.isUrlProtected(props) && includes(props.location.pathname, 'register') && this.hasAdminUser(props)) {
this.props.history.push('/plugins/users-permissions/auth/login');
// TODO: uncomment
// this.props.history.push('/plugins/users-permissions/auth/login');
}
if (!props.hasUserPlugin || auth.getToken() && !this.state.hasAlreadyRegistereOtherPlugins) {

View File

@ -40,6 +40,7 @@ export function* submitForm() {
yield put(submitSucceeded());
} catch(error) {
console.log(error.response.payload);
const formType = yield select(makeSelectFormType());
const errors = error.response.payload.message.reduce((acc, key) => {

View File

@ -26,9 +26,12 @@ module.exports = {
if (_.get(this._attributes, [current, 'type'])) {
acc[current] = params[current];
}
return acc;
}, {}));
}, {}))
.catch((error) => {
throw [{ messages: [{ id: error.message }]}];
});
},
update: async function (params) {

View File

@ -414,23 +414,23 @@
"controllers": {
"auth": {
"identity": {
"enabled": false,
"enabled": true,
"policy": ""
},
"callback": {
"enabled": false,
"enabled": true,
"policy": ""
},
"register": {
"enabled": false,
"enabled": true,
"policy": ""
},
"forgotPassword": {
"enabled": false,
"enabled": true,
"policy": ""
},
"changePassword": {
"enabled": false,
"enabled": true,
"policy": ""
}
},
@ -521,4 +521,4 @@
}
}
}
}
}

View File

@ -96,12 +96,19 @@ module.exports = {
params.password = await strapi.plugins['users-permissions'].services.user.hashPassword(params);
const user = await strapi.query('user', 'users-permissions').create(params);
try {
const user = await strapi.query('user', 'users-permissions').create(params);
ctx.send({
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
user: user
});
} catch(err) {
ctx.badRequest(null, err)
}
ctx.send({
jwt: strapi.plugins['users-permissions'].services.jwt.issue(user),
user: user
});
},
forgotPassword: async (ctx) => {