rez_core 1.0.13 → 1.0.15

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,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -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,23 @@ export class OtpController{
10
10
 
11
11
  @Post('generate')
12
12
  @HttpCode(HttpStatus.OK)
13
- async generateOtp(@Query('identifier') identifier: string, @Query('service') service: string) {
13
+ async generateOtp(@Body() request: any) {
14
+ let identifier = request.identifier;
15
+ let service = request.service;
16
+
17
+ if(!identifier || !service) {
18
+ throw new BadRequestException('Missing identifier or service!');
19
+ }
14
20
  let otp = await this.otpService.generate(identifier, service, parseInt(this.otpExpiry), parseInt(this.otpLength));
15
21
  return {'otp_id':otp.otp_id, 'success': true};
16
22
  }
17
23
 
18
24
  @Post('verify')
19
25
  @HttpCode(HttpStatus.OK)
20
- async verifyOtp(@Query('otp') otp: string, @Query('otp_id') otpId: string) {
26
+ async verifyOtp(@Body() request: any) {
27
+ let otp = request.otp;
28
+ let otpId = request.otp_id;
29
+
21
30
  let verify = await this.otpService.verifyOtp(otp, otpId);
22
31
  if (!verify) {
23
32
  throw new BadRequestException('Invalid OTP!');