|
|
@@ -3,19 +3,18 @@ import { ErrorV3 } from '@growi/core';
|
|
|
import next from 'next';
|
|
|
|
|
|
import { SupportedAction } from '~/interfaces/activity';
|
|
|
-import { LoginErrorCode } from '~/interfaces/errors/login-error';
|
|
|
import { ExternalAccountLoginError } from '~/models/vo/external-account-login-error';
|
|
|
-import { NullUsernameToBeRegisteredError } from '~/server/models/errors';
|
|
|
import { createRedirectToForUnauthenticated } from '~/server/util/createRedirectToForUnauthenticated';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
+import { externalAccountService } from '../service/external-account';
|
|
|
+
|
|
|
/* eslint-disable no-use-before-define */
|
|
|
|
|
|
module.exports = function(crowi, app) {
|
|
|
const debug = require('debug')('growi:routes:login-passport');
|
|
|
const logger = loggerFactory('growi:routes:login-passport');
|
|
|
const passport = require('passport');
|
|
|
- const ExternalAccount = crowi.model('ExternalAccount');
|
|
|
const passportService = crowi.passportService;
|
|
|
|
|
|
const activityEvent = crowi.event('activity');
|
|
|
@@ -214,7 +213,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
let externalAccount;
|
|
|
try {
|
|
|
- externalAccount = await crowi.externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
+ externalAccount = await externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
}
|
|
|
catch (error) {
|
|
|
return next(error);
|
|
|
@@ -388,7 +387,7 @@ module.exports = function(crowi, app) {
|
|
|
userInfo.username = userInfo.email.slice(0, userInfo.email.indexOf('@'));
|
|
|
}
|
|
|
|
|
|
- const externalAccount = await crowi.externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
+ const externalAccount = await externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
if (!externalAccount) {
|
|
|
return next(new ExternalAccountLoginError('message.sign_in_failure'));
|
|
|
}
|
|
|
@@ -431,7 +430,7 @@ module.exports = function(crowi, app) {
|
|
|
name: response.displayName,
|
|
|
};
|
|
|
|
|
|
- const externalAccount = await crowi.externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
+ const externalAccount = await externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
if (!externalAccount) {
|
|
|
return next(new ExternalAccountLoginError('message.sign_in_failure'));
|
|
|
}
|
|
|
@@ -481,7 +480,7 @@ module.exports = function(crowi, app) {
|
|
|
};
|
|
|
debug('mapping response to userInfo', userInfo, response, attrMapId, attrMapUserName, attrMapMail);
|
|
|
|
|
|
- const externalAccount = await crowi.externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
+ const externalAccount = await externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
if (!externalAccount) {
|
|
|
return new ExternalAccountLoginError('message.sign_in_failure');
|
|
|
}
|
|
|
@@ -540,7 +539,7 @@ module.exports = function(crowi, app) {
|
|
|
return next(new ExternalAccountLoginError('Sign in failure due to insufficient privileges.'));
|
|
|
}
|
|
|
|
|
|
- const externalAccount = await crowi.externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
+ const externalAccount = await externalAccountService.getOrCreateUser(userInfo, providerId);
|
|
|
if (!externalAccount) {
|
|
|
return next(new ExternalAccountLoginError('message.sign_in_failure'));
|
|
|
}
|