Don't sign in user when trying to connect a social account that was already created

This commit is contained in:
Phillip Thelen
2021-11-11 12:31:45 +01:00
parent 4951e82c8d
commit ced6d5e4bb
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -133,6 +133,7 @@
"unsupportedNetwork": "This network is not currently supported.",
"cantDetachSocial": "Account lacks another authentication method; can't detach this authentication method.",
"onlySocialAttachLocal": "Local authentication can be added to only a social account.",
"socialAlreadyExists": "This social login is already linked to an existing Habitica account.",
"invalidReqParams": "Invalid request parameters.",
"memberIdRequired": "\"member\" must be a valid UUID.",
"heroIdRequired": "\"heroId\" must be a valid UUID.",
+4 -1
View File
@@ -1,6 +1,6 @@
import passport from 'passport';
import common from '../../../common';
import { BadRequest } from '../errors';
import { BadRequest, NotAuthorized } from '../errors';
import logger from '../logger';
import {
generateUsername,
@@ -47,6 +47,9 @@ export async function loginSocial (req, res) { // eslint-disable-line import/pre
// User already signed up
if (user) {
if (existingUser) {
throw new NotAuthorized(res.t('socialAlreadyExists'))
}
return loginRes(user, req, res);
}