login-restrictions.js 755 B

12345678910111213141516
  1. function restrictionMessage(reply) {
  2. for (const body of [reply, reply?.error, reply?.data]) {
  3. const markers = [body?.code, body?.message, body?.mess, body?.error];
  4. if (markers.includes('ACCOUNT_BANNED')) return '此账号已被封禁,无法登录。请联系客服。';
  5. if (markers.includes('ACCOUNT_FROZEN')) return '此账号已被保护性冻结,暂时无法登录。请联系客服核验。';
  6. }
  7. return undefined;
  8. }
  9. function restrictionMessageForUser(user) {
  10. if (user?.get('isBanned') === true) return restrictionMessage({code:'ACCOUNT_BANNED'});
  11. if (user?.get('isDisabled') === true) return restrictionMessage({code:'ACCOUNT_FROZEN'});
  12. return undefined;
  13. }
  14. module.exports = {restrictionMessage,restrictionMessageForUser};