Skip to content

Commit 0940018

Browse files
committed
Make paircode always be parsable 6-digit integer
1 parent 39bfd81 commit 0940018

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

API/Controller/Devices/DevicesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Microsoft.AspNetCore.Mvc;
33
using Microsoft.EntityFrameworkCore;
44
using OpenShock.API.Models.Requests;
5-
using OpenShock.API.Services;
65
using OpenShock.Common.Authentication.Attributes;
76
using OpenShock.Common.Constants;
87
using OpenShock.Common.Errors;
@@ -12,6 +11,7 @@
1211
using OpenShock.Common.Redis;
1312
using OpenShock.Common.Utils;
1413
using System.Net.Mime;
14+
using System.Security.Cryptography;
1515
using OpenShock.API.Services.DeviceUpdate;
1616
using Redis.OM;
1717

@@ -208,7 +208,7 @@ public async Task<IActionResult> GetPairCode([FromRoute] Guid deviceId)
208208
if (!deviceExists) return Problem(HubError.HubNotFound);
209209
await _redis.Connection.UnlinkAsync($"{typeof(DevicePair).FullName}:{deviceId}");
210210

211-
string pairCode = CryptoUtils.RandomNumericString(6);
211+
string pairCode = RandomNumberGenerator.GetInt32(100000, 1000000).ToString();
212212

213213
var devicePairDto = new DevicePair
214214
{

0 commit comments

Comments
 (0)