なんかもうめっちゃ変えた
This commit is contained in:
parent
d9ab03f086
commit
b75184ec8e
946 changed files with 41219 additions and 28839 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import define from '../../../define.js';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { AuthSessionsRepository } from '@/models/index.js';
|
||||
import { AuthSessionEntityService } from '@/core/entities/AuthSessionEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '../../../error.js';
|
||||
import { AuthSessions } from '@/models/index.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['auth'],
|
||||
|
|
@ -46,15 +49,25 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
// Lookup session
|
||||
const session = await AuthSessions.findOneBy({
|
||||
token: ps.token,
|
||||
});
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
@Inject(DI.authSessionsRepository)
|
||||
private authSessionsRepository: AuthSessionsRepository,
|
||||
|
||||
if (session == null) {
|
||||
throw new ApiError(meta.errors.noSuchSession);
|
||||
private authSessionEntityService: AuthSessionEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
// Lookup session
|
||||
const session = await this.authSessionsRepository.findOneBy({
|
||||
token: ps.token,
|
||||
});
|
||||
|
||||
if (session == null) {
|
||||
throw new ApiError(meta.errors.noSuchSession);
|
||||
}
|
||||
|
||||
return await this.authSessionEntityService.pack(session, me);
|
||||
});
|
||||
}
|
||||
|
||||
return await AuthSessions.pack(session, user);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue