mirror of
https://github.com/bitwarden/server
synced 2025-12-15 07:43:54 +00:00
Replace OtpSharp with Otp.NET for net core support
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Base32;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
using OtpSharp;
|
||||
using OtpNet;
|
||||
|
||||
namespace Bit.Core.Identity
|
||||
{
|
||||
@@ -32,7 +31,7 @@ namespace Bit.Core.Identity
|
||||
|
||||
public Task<bool> ValidateAsync(string purpose, string token, UserManager<User> manager, User user)
|
||||
{
|
||||
var otp = new Totp(Base32Encoder.Decode(user.AuthenticatorKey));
|
||||
var otp = new Totp(Base32Encoding.ToBytes(user.AuthenticatorKey));
|
||||
|
||||
long timeStepMatched;
|
||||
var valid = otp.VerifyTotp(token, out timeStepMatched, new VerificationWindow(2, 2));
|
||||
|
||||
Reference in New Issue
Block a user