✨ feat(37需求): 注销账号
This commit is contained in:
@@ -307,11 +307,14 @@ export default class Auth extends Service {
|
||||
let canLogin = await this.ctx.service.utils.validateCanLogin();
|
||||
if(!canLogin) return this.ctx.service.utils.resResult(STATUS.ONLINE_USER_MAX);
|
||||
|
||||
const role = await RoleModel.findByUid(uid, serverId);
|
||||
const role = await RoleModel.findByUid(uid, serverId, 'roleId blockType +closeTime');
|
||||
if (role) {
|
||||
if(role.blockType == BLOCK_TYPE.BLOCK) {
|
||||
return ctx.service.utils.resResult(STATUS.BLOCKED);
|
||||
}
|
||||
if(role.closeTime > 0 && role.closeTime < nowSeconds()) {
|
||||
return ctx.service.utils.resResult(STATUS.ROLE_CLOSED);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
|
||||
@@ -480,5 +483,19 @@ export default class Auth extends Service {
|
||||
if(!result) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
public async closeAccount(roleId: string) {
|
||||
const ctx = this.ctx;
|
||||
let role = await RoleModel.closeAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
|
||||
if(!role) return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
|
||||
}
|
||||
|
||||
public async cancelCloseAccount(roleId: string) {
|
||||
const ctx = this.ctx;
|
||||
let role = await RoleModel.cancelCloseAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
|
||||
if(!role) return ctx.service.utils.resResult(STATUS.ROLE_CLOSE_TIME_OVER);
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -560,7 +560,9 @@ export default class Sdk extends Service {
|
||||
let redisClient: RedisClient = this.ctx.app.context.redisClient;
|
||||
let servers = await redisClient.hgetallAsync(REDIS_KEY.SERVER);
|
||||
let roles = await RoleModel.findAllByUid(user.uid);
|
||||
let result = roles.map(role => ({
|
||||
let result = roles
|
||||
.filter(role => role.closeTime > 0 && role.closeTime < nowSeconds())
|
||||
.map(role => ({
|
||||
id: role.roleId,
|
||||
name: role.roleName,
|
||||
level: role.lv.toString(),
|
||||
|
||||
Reference in New Issue
Block a user