role
This commit is contained in:
@@ -19,7 +19,7 @@ export class AdminAuthController {
|
||||
@ApiResponse({ status: 201, description: 'OTP requested successfully' })
|
||||
@ApiResponse({ status: 400, description: 'Invalid mobile number' })
|
||||
otpRequest(@Body() dto: RequestOtpDto) {
|
||||
return this.authService.requestOtp(dto);
|
||||
return this.authService.requestOtpAdmin(dto);
|
||||
}
|
||||
|
||||
@Post('otp/verify')
|
||||
@@ -28,7 +28,7 @@ export class AdminAuthController {
|
||||
@ApiResponse({ status: 200, description: 'OTP verified successfully' })
|
||||
@ApiResponse({ status: 400, description: 'Invalid OTP or expired' })
|
||||
otpVerify(@Body() dto: VerifyOtpDto) {
|
||||
return this.authService.verifyOtp(dto.phone, dto.slug, dto.otp); // assuming dto has `otp` property
|
||||
return this.authService.verifyOtpAdmin(dto.phone, dto.slug, dto.otp); // assuming dto has `otp` property
|
||||
}
|
||||
|
||||
// @Post('admin/otp/request')
|
||||
|
||||
@@ -71,7 +71,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async verifyOtpAdmin(phone: string, slug: string, code: string) {
|
||||
const cachedCode = await this.cacheService.get(`otp:${slug}:${phone}`);
|
||||
const cachedCode = await this.cacheService.get(`otp-admin:${slug}:${phone}`);
|
||||
if (!cachedCode) throw new BadRequestException('OTP expired or not found');
|
||||
if (cachedCode !== code) throw new BadRequestException('Invalid OTP');
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ import { AuthMessage, UserMessage } from '../../../common/enums/message.enum';
|
||||
import { RefreshToken } from '../../users/entities/refresh-token.entity';
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
import { IAdminTokenPayload, ITokenPayload } from '../interfaces/IToken-payload';
|
||||
import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity';
|
||||
import { RestRepository } from 'src/modules/restaurants/repositories/rest.repository';
|
||||
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||
import { CacheService } from 'src/modules/utils/cache.service';
|
||||
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
|
||||
import { RestRepository } from '../../restaurants/repositories/rest.repository';
|
||||
import { Admin } from '../../admin/entities/admin.entity';
|
||||
import { CacheService } from '../../utils/cache.service';
|
||||
|
||||
@Injectable()
|
||||
export class TokensService {
|
||||
|
||||
Reference in New Issue
Block a user