Commit 448f7f5e authored by ml's avatar ml

资产管理后台-账户管理、登陆、谷歌等

parent c6a45512
...@@ -121,7 +121,7 @@ export const getInfoDetailByUserId = async (req: any, abkUserInfoVO: AbkUserInfo ...@@ -121,7 +121,7 @@ export const getInfoDetailByUserId = async (req: any, abkUserInfoVO: AbkUserInfo
/** /**
* 重置谷歌-生成一个新的密钥返回,保存时重新绑定谷歌 * 重置谷歌
* @param req * @param req
* @param authConfigVO * @param authConfigVO
*/ */
...@@ -131,6 +131,9 @@ export const resetTotp = async (req: any, abkUserInfoVO: AbkUserInfoVO) => { ...@@ -131,6 +131,9 @@ export const resetTotp = async (req: any, abkUserInfoVO: AbkUserInfoVO) => {
try { try {
let currentUserId = await getCurrentUserId(req.cookies.session_id); let currentUserId = await getCurrentUserId(req.cookies.session_id);
await isSuperUser(currentUserId) await isSuperUser(currentUserId)
if (!abkUserInfoVO.user_id){
throw ErrorCode.PARAM_MISS;
}
let res = await abkUserService.resetAbkTotp(abkUserInfoVO.user_id); let res = await abkUserService.resetAbkTotp(abkUserInfoVO.user_id);
return Res3Utils.result(res); return Res3Utils.result(res);
} }
...@@ -141,6 +144,27 @@ export const resetTotp = async (req: any, abkUserInfoVO: AbkUserInfoVO) => { ...@@ -141,6 +144,27 @@ export const resetTotp = async (req: any, abkUserInfoVO: AbkUserInfoVO) => {
}; };
/**
* 获取谷歌密钥-生成一个新的密钥返回
* @param req
* @param authConfigVO
*/
export const getTotp = async (req: any, abkUserInfoVO: AbkUserInfoVO) => {
let func_name = "abkUserInfo.control.resetTotp";
let cmd = req.path;
try {
let currentUserId = await getCurrentUserId(req.cookies.session_id);
await isSuperUser(currentUserId)
let res = await abkUserService.getAbkTotp(abkUserInfoVO.user_id);
return Res3Utils.result(res);
}
catch (e) {
logger.error(`${func_name} error:${e}`);
return Res3Utils.getErrorResult(e);
}
};
/** /**
* 获取用户列表 * 获取用户列表
* @param req * @param req
...@@ -192,8 +216,8 @@ export const updateStatus = async (req: any, abkUserInfoPageVO: AbkUserInfoPageV ...@@ -192,8 +216,8 @@ export const updateStatus = async (req: any, abkUserInfoPageVO: AbkUserInfoPageV
function checkPwd(pwd: string) { function checkPwd(pwd: string) {
let reg = /^(?=.[0-9])(?=.[A-Z])(?=.[a-z])(?=.[!@#%^&*?]).{8,12}$/; let regExp = new RegExp('^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,12}$');
if (!reg.test(pwd)) { if (!regExp.test(pwd)) {
throw ErrorCode.PWD_FORMAT_ERR; throw ErrorCode.PWD_FORMAT_ERR;
} }
} }
......
...@@ -209,6 +209,24 @@ export async function resetAbkTotp(userId: number | undefined) { ...@@ -209,6 +209,24 @@ export async function resetAbkTotp(userId: number | undefined) {
let userInfo = await getOneAbkUserByUid(Number(userId)); let userInfo = await getOneAbkUserByUid(Number(userId));
ApiAssert.isNotEmpty(ErrorCode.USER_NOT_EXIST, userInfo); ApiAssert.isNotEmpty(ErrorCode.USER_NOT_EXIST, userInfo);
} }
//生成新的密钥
let totpEncrypt = Otplib.authenticator.generateSecret();
let email = userId ? userId : 0 + '-' + totpEncrypt.slice(0, 3)
let uri = 'otpauth://totp/' + email + '?secret=' + totpEncrypt + '&issuer=team888';
await abkUserInfo.prototype.update({
totp_encrypt: totpEncrypt
},
{
where: {
user_id: Number(userId)
}
});
//踢出登陆
await deleteAllAbkSessionByUserId(Number(userId));
return { uri: uri, totpEncrypt: totpEncrypt };
}
export async function getAbkTotp(userId: number | undefined) {
//生成新的密钥 //生成新的密钥
let totpEncrypt = Otplib.authenticator.generateSecret(); let totpEncrypt = Otplib.authenticator.generateSecret();
let email = userId ? userId : 0 + '-' + totpEncrypt.slice(0, 3) let email = userId ? userId : 0 + '-' + totpEncrypt.slice(0, 3)
...@@ -237,12 +255,25 @@ export async function userList(abkUserInfoPageVO: AbkUserInfoPageVO, currentUser ...@@ -237,12 +255,25 @@ export async function userList(abkUserInfoPageVO: AbkUserInfoPageVO, currentUser
} }
export async function updateStatus(user_id: number, user_status: number, currentUserId: any) { export async function updateStatus(user_id: number, user_status: number, currentUserId: any) {
await getOneAbkUserByUid(user_id) await getOneAbkUserByUid(user_id);
await updateAbkUserStatus(user_id, user_status); await updateAbkUserStatus(user_id, user_status);
//停用或删除 踢出登陆
if ([AbkUserInfoConst.USER_STATUS.STOP,AbkUserInfoConst.USER_STATUS.DEL].includes(Number(user_status))){
await deleteAllAbkSessionByUserId(user_id);
}
return 'success'; return 'success';
} }
export async function addAbkUser(abkUserInfoVO: AbkUserInfoVO) { export async function addAbkUser(abkUserInfoVO: AbkUserInfoVO) {
let dbInfo = await abkUserInfo.prototype.findOne({
where: {
account: abkUserInfoVO.account,
},
raw: true
});
if (dbInfo){
throw ErrorCode.USER_EXIST;
}
let insertData = { let insertData = {
account: abkUserInfoVO.account, account: abkUserInfoVO.account,
pwd: abkUserInfoVO.pwd, pwd: abkUserInfoVO.pwd,
......
...@@ -21,6 +21,7 @@ const postFunc = { ...@@ -21,6 +21,7 @@ const postFunc = {
'abkUser/getInfo': abkUserCtrl.getInfo, 'abkUser/getInfo': abkUserCtrl.getInfo,
'abkUser/getInfoDetailByUserId': abkUserCtrl.getInfoDetailByUserId, 'abkUser/getInfoDetailByUserId': abkUserCtrl.getInfoDetailByUserId,
'abkUser/reset/totp': abkUserCtrl.resetTotp, 'abkUser/reset/totp': abkUserCtrl.resetTotp,
'abkUser/get/totp': abkUserCtrl.getTotp,
'abkUser/list': abkUserCtrl.userList, 'abkUser/list': abkUserCtrl.userList,
'abkUser/updateStatus': abkUserCtrl.updateStatus, 'abkUser/updateStatus': abkUserCtrl.updateStatus,
'abkUser/addUser': abkUserCtrl.addAbkUser, 'abkUser/addUser': abkUserCtrl.addAbkUser,
......
...@@ -12,25 +12,18 @@ import * as ReqUtils from "../utils/req-utils" ...@@ -12,25 +12,18 @@ import * as ReqUtils from "../utils/req-utils"
const CLASS_NAME = "login-filter"; const CLASS_NAME = "login-filter";
const ExcludeApi = { const ExcludeApi = {
"user/login": 1, "abkUser/login": 1,
"user/logout": 1, "abkUser/logout": 1,
"user/login/confirm": 1,
"mUser/fee/vip/level/list": 1,
"spotPair/getAllSubmitSuccess": 1,
"coinType/getAllSubmitSuccess": 1,
'acl/role/getAll': 1,
'position/allList': 1,
'department/allList': 1,
'operate/other/business/area/list': 1,
}; };
let filter = function (app: any) { let filter = function (app: any) {
app.use(function (req, res, next) { app.use(function (req, res, next) {
let path = req.originalUrl; let path = req.originalUrl;
let pathR = req.originalUrl.replace(Config.BASE_ABK_URL,"");
try { try {
// Madex 管理后台的接口 跳过 // Madex 管理后台的接口 跳过
if (ExcludeApi[path] || path.startsWith(Config.BASE_URL)) { if (ExcludeApi[pathR] || path.startsWith(Config.BASE_URL)) {
next(); next();
} }
else { else {
......
'use strict'; 'use strict';
import * as ReqUtils from "../utils/req-utils"; import * as ReqUtils from "../utils/req-utils";
import * as pairApplyCtrl from "../functional/mvc/control/pairApply.control"; import Config from "../../config";
const { const {
Res3Utils, Res3Utils,
logger: Logger, logger: Logger,
...@@ -233,17 +232,13 @@ let cmdWhiteList = { ...@@ -233,17 +232,13 @@ let cmdWhiteList = {
'tech/other/reward/time/period/get': 1, 'tech/other/reward/time/period/get': 1,
}; };
//资产管理后台
let abkCmdWhiteList = {
};
let filter = function (app: any) { let filter = function (app: any) {
app.use(function (req, res, next) { app.use(function (req, res, next) {
let path = ReqUtils.parsePath(req.originalUrl); let path = ReqUtils.parsePath(req.originalUrl);
try { try {
if (!cmdWhiteList[path] && !abkCmdWhiteList[path]) { if (!cmdWhiteList[path] && !path.startsWith(Config.BASE_ABK_URL)) {
throw '3000' throw '3000'
} }
next(); next();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment