Initial commit: Telegram Management System
Some checks failed
Deploy / deploy (push) Has been cancelled
Some checks failed
Deploy / deploy (push) Has been cancelled
Full-stack web application for Telegram management - Frontend: Vue 3 + Vben Admin - Backend: NestJS - Features: User management, group broadcast, statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
24
backend-nestjs/src/modules/auth/strategies/local.strategy.ts
Normal file
24
backend-nestjs/src/modules/auth/strategies/local.strategy.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Strategy } from 'passport-local';
|
||||
|
||||
import { AuthService } from '../auth.service';
|
||||
import { Admin } from '@database/entities/admin.entity';
|
||||
|
||||
@Injectable()
|
||||
export class LocalStrategy extends PassportStrategy(Strategy) {
|
||||
constructor(private readonly authService: AuthService) {
|
||||
super({
|
||||
usernameField: 'account',
|
||||
passwordField: 'password',
|
||||
});
|
||||
}
|
||||
|
||||
async validate(account: string, password: string): Promise<Admin> {
|
||||
const admin = await this.authService.validateUser(account, password);
|
||||
if (!admin) {
|
||||
throw new UnauthorizedException('账号或密码错误');
|
||||
}
|
||||
return admin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user