api-v3-test-attach-local-to-social-auth

This commit is contained in:
Victor Piousbox
2016-03-24 17:51:31 +00:00
parent 1d3c67af40
commit 528d805cda
2 changed files with 36 additions and 3 deletions
+2 -3
View File
@@ -70,7 +70,7 @@ api.registerLocal = {
url: '/user/auth/local/register',
async handler (req, res) {
let fbUser = res.locals.user; // If adding local auth to social user
// TODO check user doesn't have local auth
req.checkBody({
email: {
notEmpty: {errorMessage: res.t('missingEmail')},
@@ -82,7 +82,6 @@ api.registerLocal = {
equals: {options: [req.body.confirmPassword], errorMessage: res.t('passwordConfirmationMatch')},
},
});
let validationErrors = req.validationErrors();
if (validationErrors) throw validationErrors;
@@ -124,7 +123,7 @@ api.registerLocal = {
if (fbUser) {
if (!fbUser.auth.facebook.id) throw new NotAuthorized(res.t('onlySocialAttachLocal'));
fbUser.auth.local = newUser;
fbUser.auth.local = newUser.auth.local;
newUser = fbUser;
} else {
newUser = new User(newUser);