feat: complete cmpp platform phases 0-5

This commit is contained in:
hectorzhao
2026-07-01 13:22:04 +08:00
parent 824a8b334f
commit ee926fea04
86 changed files with 10490 additions and 14 deletions
+30
View File
@@ -0,0 +1,30 @@
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { hashPassword, UsersService } from '../users/users.service';
export interface LoginDto {
username: string;
password: string;
}
@Injectable()
export class AuthService {
constructor(private readonly users: UsersService) {}
async login(data: LoginDto) {
const user = await this.users.findByUsername(data.username);
if (!user || user.passwordHash !== hashPassword(data.password) || user.status !== 'active') {
throw new UnauthorizedException('Invalid username or password');
}
return {
accessToken: `dev-token-${user.id}`,
tokenType: 'Bearer',
user: {
id: user.id,
tenantId: user.tenantId,
username: user.username,
displayName: user.displayName,
},
};
}
}