modified saveuserstatus to handle incactive case
MODIFY
src/server/rest/v1/service/AuthService.ts
src/server/rest/v1/service/AuthService.ts
@@ -15,6 +15,7 @@ import I18nManager from '../../../../utils/I18nManager';
import Logging from '../../../../utils/Logging';
import NotificationHandler from '../../../../notification/NotificationHandler';
import { ServerAction } from '../../../../types/Server';
+import SettingStorage from '../../../../storage/mongodb/SettingStorage';
import SiteStorage from '../../../../storage/mongodb/SiteStorage';
import { StatusCodes } from 'http-status-codes';
import Tag from '../../../../types/Tag';
@@ -651,8 +652,10 @@ export default class AuthService {
message: 'Wrong Verification Token'
});
}
+ const accountActivationSetting = await SettingStorage.getSettingByIdentifier(tenantID, 'accountActivation');
+ const userStatus = accountActivationSetting.doNotActivateByDefault ? UserStatus.INACTIVE : UserStatus.ACTIVE;
// Save User Status
- await UserStorage.saveUserStatus(tenantID, user.id, UserStatus.ACTIVE);
+ await UserStorage.saveUserStatus(tenantID, user.id, userStatus);
// For integration with billing
const billingImpl = await BillingFactory.getBillingImpl(tenantID);
if (billingImpl) {
@@ -685,11 +688,11 @@ export default class AuthService {
tenantID: tenantID,
user: user, action: action,
module: MODULE_NAME, method: 'handleVerifyEmail',
- message: 'User account has been successfully verified and activated',
+ message: userStatus === UserStatus.ACTIVE ? 'User account has been successfully verified and activated' : 'User account has been successfully verified but needs an admin to activate it',
detailedMessages: { params: req.query }
});
// Ok
- res.json(Constants.REST_RESPONSE_SUCCESS);
+ res.json(userStatus === UserStatus.ACTIVE ? Constants.REST_RESPONSE_SUCCESS : { status: 'Success', userStatus: 'inactive' });
next();
}

modified saveuserstatus to handle incactive case