mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
支持多端登录
This commit is contained in:
+15
-3
@@ -1,6 +1,6 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import winston from 'winston';
|
||||
import { createRandomString, getNetIp } from '../config/util';
|
||||
import { createRandomString, getNetIp, getPlatform } from '../config/util';
|
||||
import config from '../config';
|
||||
import * as fs from 'fs';
|
||||
import _ from 'lodash';
|
||||
@@ -29,7 +29,7 @@ export default class AuthService {
|
||||
username: string;
|
||||
password: string;
|
||||
},
|
||||
req: any,
|
||||
req: Request,
|
||||
needTwoFactor = true,
|
||||
): Promise<any> {
|
||||
if (!fs.existsSync(config.authConfigFile)) {
|
||||
@@ -49,6 +49,7 @@ export default class AuthService {
|
||||
lastaddr,
|
||||
twoFactorActivated,
|
||||
twoFactorActived,
|
||||
tokens = {},
|
||||
} = content;
|
||||
// patch old field
|
||||
twoFactorActivated = twoFactorActivated || twoFactorActived;
|
||||
@@ -94,6 +95,10 @@ export default class AuthService {
|
||||
|
||||
this.updateAuthInfo(content, {
|
||||
token,
|
||||
tokens: {
|
||||
...tokens,
|
||||
[req.platform]: token,
|
||||
},
|
||||
lastlogon: timestamp,
|
||||
retries: 0,
|
||||
lastip: ip,
|
||||
@@ -214,7 +219,14 @@ export default class AuthService {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public async twoFactorLogin({ username, password, code }, req) {
|
||||
public async twoFactorLogin(
|
||||
{
|
||||
username,
|
||||
password,
|
||||
code,
|
||||
}: { username: string; password: string; code: string },
|
||||
req: any,
|
||||
) {
|
||||
const authInfo = this.getAuthInfo();
|
||||
const { isTwoFactorChecking, twoFactorSecret } = authInfo;
|
||||
if (!isTwoFactorChecking) {
|
||||
|
||||
Reference in New Issue
Block a user