You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
UseGuards,
|
|
Post,
|
|
Put,
|
|
UsePipes,
|
|
Body,
|
|
Query,
|
|
HttpCode,
|
|
Res,
|
|
Req,
|
|
} from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import fs from 'fs';
|
|
|
|
import { ValidationPipe, User, Roles, RolesGuard } from '../common';
|
|
import { AuthService } from './auth.service';
|
|
import { Login, PollingDto, LoginMobile, ResponseType, UpdateUserDto, IsLogin, QrResponse, SureLogin, IsLoginResult, LoginStatus, } from './auth.params';
|
|
import { UserEntity } from '../user/user.entity';
|
|
import redis from 'src/redis';
|
|
import { v4 as uuid } from 'uuid';
|
|
import Axios from 'axios';
|
|
|
|
@ApiTags('用户登录')
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(
|
|
private readonly authService: AuthService,
|
|
@InjectRepository(UserEntity)
|
|
private readonly userRepository: Repository<UserEntity>,
|
|
) { }
|
|
|
|
@Get('login/status/is_login')
|
|
@ApiOperation({ summary: '获取 token 是否失效' })
|
|
@UsePipes(new ValidationPipe())
|
|
@ApiResponse({
|
|
status: 200,
|
|
description: '返回参数说明',
|
|
type: LoginStatus,
|
|
})
|
|
async loginGetStatus(@Query() loginData: IsLogin): Promise<any> {
|
|
const result = await redis.get(`qunsense_code:${loginData.qunsense_code}`)
|
|
if (result) {
|
|
return {
|
|
status: true
|
|
}
|
|
}
|
|
return {
|
|
status: false
|
|
}
|
|
}
|
|
}
|