Don't sign in user when trying to connect a social account that was already created
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user