mirror of
https://github.com/certd/certd.git
synced 2026-05-15 20:47:31 +08:00
chore: 目录调整,controller转移到外部单独的目录
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { Body, Controller, Inject, Post, Provide, ALL } from '@midwayjs/core';
|
||||
import { LoginService } from '../../modules/login/service/login-service.js';
|
||||
import { BaseController } from '@certd/lib-server';
|
||||
import { Constants } from '@certd/lib-server';
|
||||
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/')
|
||||
export class LoginController extends BaseController {
|
||||
@Inject()
|
||||
loginService: LoginService;
|
||||
@Post('/login', { summary: Constants.per.guest })
|
||||
public async login(
|
||||
@Body(ALL)
|
||||
user: any
|
||||
) {
|
||||
const token = await this.loginService.login(user);
|
||||
|
||||
this.ctx.cookies.set('token', token.token, {
|
||||
maxAge: 1000 * token.expire,
|
||||
});
|
||||
|
||||
return this.ok(token);
|
||||
}
|
||||
|
||||
@Post('/logout', { summary: Constants.per.authOnly })
|
||||
public logout() {}
|
||||
}
|
||||
Reference in New Issue
Block a user