mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
perf: 支持oidc单点登录
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { cache, isDev, randomNumber } from '@certd/basic';
|
||||
import { cache, isDev, randomNumber, simpleNanoId } from '@certd/basic';
|
||||
import { SysSettingsService, SysSiteInfo } from '@certd/lib-server';
|
||||
import { SmsServiceFactory } from '../sms/factory.js';
|
||||
import { ISmsService } from '../sms/api.js';
|
||||
@@ -188,4 +188,20 @@ export class CodeService {
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
buildValidationValueKey(code:string) {
|
||||
return `validationValue:${code}`;
|
||||
}
|
||||
setValidationValue(value:any) {
|
||||
const randomCode = simpleNanoId(12);
|
||||
const key = this.buildValidationValueKey(randomCode);
|
||||
cache.set(key, value, {
|
||||
ttl: 5 * 60 * 1000, //5分钟
|
||||
});
|
||||
return randomCode;
|
||||
}
|
||||
getValidationValue(code:string) {
|
||||
return cache.get(this.buildValidationValueKey(code));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user