mirror of https://github.com/certd/certd
perf: 重置管理员密码同时启用管理员账户,避免之前禁用了,重置密码还是登录不进去
parent
13eb0231ac
commit
f92d918a1e
|
@ -28,18 +28,14 @@ services:
|
||||||
# 设置环境变量即可自定义certd配置
|
# 设置环境变量即可自定义certd配置
|
||||||
# 配置项见: packages/ui/certd-server/src/config/config.default.ts
|
# 配置项见: packages/ui/certd-server/src/config/config.default.ts
|
||||||
# 配置规则: certd_ + 配置项, 点号用_代替
|
# 配置规则: certd_ + 配置项, 点号用_代替
|
||||||
|
|
||||||
# ↓↓↓↓ ------------------------------------ 这里可以设置http代理
|
|
||||||
#- HTTPS_PROXY=http://xxxxxx:xx
|
|
||||||
#- HTTP_PROXY=http://xxxxxx:xx
|
|
||||||
# ↓↓↓↓ ----------------------------- 如果忘记管理员密码,可以设置为true,重启之后,管理员密码将改成123456,然后请及时修改回false
|
# ↓↓↓↓ ----------------------------- 如果忘记管理员密码,可以设置为true,重启之后,管理员密码将改成123456,然后请及时修改回false
|
||||||
- certd_system_resetAdminPasswd=false
|
- certd_system_resetAdminPasswd=false
|
||||||
# ↓↓↓↓ -------------------------- 如果设置为true,启动后所有配置了cron的流水线任务都将被立即触发一次
|
# ↓↓↓↓ -------------------------------- 默认同时启动https,https访问地址https://your.domain:7002
|
||||||
- certd_cron_immediateTriggerOnce=false
|
#- certd_https_key=./data/ssl/cert.key
|
||||||
# ↓↓↓↓ -------------------------------- 配置证书和key,则表示https方式启动,使用https协议访问,https://your.domain:7001
|
#- certd_https_cert=./data/ssl/cert.crt
|
||||||
#- certd_koa_key=./data/ssl/cert.key
|
#- certd_https_enabled=true
|
||||||
#- certd_koa_cert=./data/ssl/cert.crt
|
#- certd_https_port=7002
|
||||||
|
-
|
||||||
# ↓↓↓↓ ------------------------------- 使用postgresql数据库
|
# ↓↓↓↓ ------------------------------- 使用postgresql数据库
|
||||||
# - certd_flyway_scriptDir=./db/migration-pg # 升级脚本目录
|
# - certd_flyway_scriptDir=./db/migration-pg # 升级脚本目录
|
||||||
# - certd_typeorm_dataSource_default_type=postgres # 数据库类型
|
# - certd_typeorm_dataSource_default_type=postgres # 数据库类型
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -30,6 +30,7 @@ export class ResetPasswdMiddleware implements IWebMiddleware {
|
||||||
logger.info('开始重置1号管理员用户的密码');
|
logger.info('开始重置1号管理员用户的密码');
|
||||||
const newPasswd = '123456';
|
const newPasswd = '123456';
|
||||||
await this.userService.resetPassword(1, newPasswd);
|
await this.userService.resetPassword(1, newPasswd);
|
||||||
|
await this.userService.updateStatus(1, 1);
|
||||||
logger.info(`重置1号管理员用户的密码完成,新密码为:${newPasswd}`);
|
logger.info(`重置1号管理员用户的密码完成,新密码为:${newPasswd}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,9 @@ export class UserService extends BaseService<UserEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetPassword(userId: any, newPasswd: string) {
|
async resetPassword(userId: any, newPasswd: string) {
|
||||||
|
if (!userId) {
|
||||||
|
throw new CommonException('userId不能为空');
|
||||||
|
}
|
||||||
const param = {
|
const param = {
|
||||||
id: userId,
|
id: userId,
|
||||||
password: newPasswd,
|
password: newPasswd,
|
||||||
|
@ -210,15 +213,19 @@ export class UserService extends BaseService<UserEntity> {
|
||||||
ids = ids.split(',');
|
ids = ids.split(',');
|
||||||
ids = ids.map(id => parseInt(id));
|
ids = ids.map(id => parseInt(id));
|
||||||
}
|
}
|
||||||
if (ids instanceof Array) {
|
if (ids.length === 0) {
|
||||||
if (ids.includes(1)) {
|
return;
|
||||||
throw new CommonException('不能删除管理员');
|
}
|
||||||
}
|
if (ids.includes(1)) {
|
||||||
|
throw new CommonException('不能删除管理员');
|
||||||
}
|
}
|
||||||
await super.delete(ids);
|
await super.delete(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
async isAdmin(userId: any) {
|
async isAdmin(userId: any) {
|
||||||
|
if (!userId) {
|
||||||
|
throw new CommonException('userId不能为空');
|
||||||
|
}
|
||||||
const userRoles = await this.userRoleService.find({
|
const userRoles = await this.userRoleService.find({
|
||||||
where: {
|
where: {
|
||||||
userId,
|
userId,
|
||||||
|
@ -229,4 +236,13 @@ export class UserService extends BaseService<UserEntity> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async updateStatus(id: number, status: number) {
|
||||||
|
if (!id) {
|
||||||
|
throw new CommonException('userId不能为空');
|
||||||
|
}
|
||||||
|
await this.repository.update(id, {
|
||||||
|
status,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue