完善auth服务注释
This commit is contained in:
@@ -5,27 +5,33 @@ import { LoginDto } from './dto/login.dto';
|
|||||||
export class AuthService {
|
export class AuthService {
|
||||||
async loginWithPassword(loginDto: LoginDto) {
|
async loginWithPassword(loginDto: LoginDto) {
|
||||||
const { account, password } = loginDto;
|
const { account, password } = loginDto;
|
||||||
if (!account || !password) {
|
// 依次使用账号、手机号、邮箱登录
|
||||||
throw new BadRequestException('account and password are required');
|
|
||||||
}
|
|
||||||
|
|
||||||
return { message: 'Logged in with password', data: loginDto };
|
return { message: 'Logged in with password', data: loginDto };
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginWithPhone(loginDto: LoginDto) {
|
async loginWithPhone(loginDto: LoginDto) {
|
||||||
const { phone, code } = loginDto;
|
const { phone, code } = loginDto;
|
||||||
if (!phone || !code) {
|
// 先判断验证码是否正确
|
||||||
throw new BadRequestException('Phone number and code are required');
|
|
||||||
}
|
|
||||||
|
// 判断用户是否存在,若不存在则进行注册
|
||||||
|
|
||||||
|
|
||||||
|
// 登录,颁发token
|
||||||
|
|
||||||
return { message: 'Logged in with phone', data: loginDto };
|
return { message: 'Logged in with phone', data: loginDto };
|
||||||
}
|
}
|
||||||
|
|
||||||
async loginWithEmail(loginDto: LoginDto) {
|
async loginWithEmail(loginDto: LoginDto) {
|
||||||
const { email, code } = loginDto;
|
const { email, code } = loginDto;
|
||||||
if (!email || !code) {
|
// 先判断验证码是否正确
|
||||||
throw new BadRequestException('Email and code are required');
|
|
||||||
}
|
|
||||||
|
// 判断用户是否存在,若不存在则进行注册
|
||||||
|
|
||||||
|
|
||||||
|
// 登录,颁发token
|
||||||
|
|
||||||
return { message: 'Logged in with email', data: loginDto };
|
return { message: 'Logged in with email', data: loginDto };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user