mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: support oauth bind/unbind account (#971)
Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
1 parent
1a8232899c
commit
536c697f4b
16 files changed
+393
-141
No files matched your search
@@ -3,7 +3,7 @@ import { Logger } from '@hydrooj/utils';
|
||||
import { Context, Service } from '../context';
|
||||
import * as system from '../model/system';
|
||||
|
||||
export type MigrationScript = null | (() => Promise<boolean | void>);
|
||||
export type MigrationScript = null | ((ctx: Context) => Promise<boolean | void>);
|
||||
const logger = new Logger('migration');
|
||||
|
||||
declare module '../context' {
|
||||
@@ -39,7 +39,7 @@ export default class MigrationService extends Service {
|
||||
const isFresh = !dbVer;
|
||||
const expected = scripts.length;
|
||||
if (isFresh) {
|
||||
await scripts[0]?.();
|
||||
await scripts[0]?.(this.ctx);
|
||||
await system.set(name, expected);
|
||||
continue;
|
||||
}
|
||||
@@ -53,11 +53,11 @@ export default class MigrationService extends Service {
|
||||
if ('dontWait' in func) {
|
||||
logger.info('[Background Task]');
|
||||
// For those scripts we don't really care if they fail
|
||||
func().then(() => {
|
||||
func(this.ctx).then(() => {
|
||||
logger.info('Background Task Completed [%s]: from %d to %d', channel, func.dontWait, expected);
|
||||
}).catch(logger.error);
|
||||
} else {
|
||||
const result = await func();
|
||||
const result = await func(this.ctx);
|
||||
if (!result) break;
|
||||
}
|
||||
dbVer++;
|
||||
|
||||
@@ -264,6 +264,7 @@ export async function apply(ctx: Context) {
|
||||
id: key,
|
||||
icon: global.Hydro.module.oauth[key].icon,
|
||||
text: global.Hydro.module.oauth[key].text,
|
||||
name: global.Hydro.module.oauth[key].name,
|
||||
}));
|
||||
if (!h.noCheckPermView && !h.user.hasPriv(PRIV.PRIV_VIEW_ALL_DOMAIN)) h.checkPerm(PERM.PERM_VIEW);
|
||||
if (h.context.pendingError) throw h.context.pendingError;
|
||||
|
||||
Reference in new issue
Block a user