rez_core 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BadRequestException, Controller, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Body, Controller, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
|
2
2
|
import { OtpService } from '../service/otp.service';
|
|
3
3
|
|
|
4
4
|
@Controller('api/otp')
|
|
@@ -10,14 +10,14 @@ export class OtpController{
|
|
|
10
10
|
|
|
11
11
|
@Post('generate')
|
|
12
12
|
@HttpCode(HttpStatus.OK)
|
|
13
|
-
async generateOtp(@
|
|
13
|
+
async generateOtp(@Body('identifier') identifier: string, @Body('service') service: string) {
|
|
14
14
|
let otp = await this.otpService.generate(identifier, service, parseInt(this.otpExpiry), parseInt(this.otpLength));
|
|
15
15
|
return {'otp_id':otp.otp_id, 'success': true};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@Post('verify')
|
|
19
19
|
@HttpCode(HttpStatus.OK)
|
|
20
|
-
async verifyOtp(@
|
|
20
|
+
async verifyOtp(@Body('otp') otp: string, @Body('otp_id') otpId: string) {
|
|
21
21
|
let verify = await this.otpService.verifyOtp(otp, otpId);
|
|
22
22
|
if (!verify) {
|
|
23
23
|
throw new BadRequestException('Invalid OTP!');
|