Skip to content

Commit

Permalink
Fix property naming
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Jun 14, 2024
1 parent 54525ff commit 41a6592
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Nager.Authentication.Abstraction/Entities/UserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class UserEntity
public DateTime? LastSuccessfulValidationTimestamp { get; set; }

[MaxLength(32)]
public byte[]? mfaSecret { get; set; }
public byte[]? MfaSecret { get; set; }

public bool mfaActive { get; set; }
public bool MfaActive { get; set; }

public bool IsLocked { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.1</TargetFramework>

<Version>2.0.0</Version>
<Version>2.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<Nullable>enable</Nullable>

<Version>2.0.0</Version>
<Version>2.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Nager.Authentication/Nager.Authentication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Nullable>enable</Nullable>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>

<Version>2.0.0</Version>
<Version>2.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions src/Nager.Authentication/Services/UserAccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ private async Task<bool> CreateMfaSecretAsync(
return false;
}

if (userEntity.mfaSecret == null)
if (userEntity.MfaSecret == null)
{
userEntity.mfaSecret = ByteHelper.CreatePseudoRandomNumber();
userEntity.MfaSecret = ByteHelper.CreatePseudoRandomNumber();
return await this._userRepository.UpdateAsync(userEntity, cancellationToken);
}

Expand All @@ -88,15 +88,15 @@ public async Task<MfaActivationResult> ActivateMfaAsync(
return MfaActivationResult.UserNotFound;
}

if (userEntity.mfaActive)
if (userEntity.MfaActive)
{
return MfaActivationResult.AlreadyActive;
}

var twoFactorAuthenticator = new TwoFactorAuthenticator();
if (twoFactorAuthenticator.ValidateTwoFactorPIN(userEntity.mfaSecret, token))
if (twoFactorAuthenticator.ValidateTwoFactorPIN(userEntity.MfaSecret, token))
{
userEntity.mfaActive = true;
userEntity.MfaActive = true;
if (await this._userRepository.UpdateAsync(userEntity, cancellationToken))
{
return MfaActivationResult.Success;
Expand All @@ -120,16 +120,16 @@ public async Task<MfaDeactivationResult> DeactivateMfaAsync(
return MfaDeactivationResult.UserNotFound;
}

if (!userEntity.mfaActive)
if (!userEntity.MfaActive)
{
return MfaDeactivationResult.NotActive;
}

var twoFactorAuthenticator = new TwoFactorAuthenticator();
if (twoFactorAuthenticator.ValidateTwoFactorPIN(userEntity.mfaSecret, token))
if (twoFactorAuthenticator.ValidateTwoFactorPIN(userEntity.MfaSecret, token))
{
userEntity.mfaActive = false;
userEntity.mfaSecret = null;
userEntity.MfaActive = false;
userEntity.MfaSecret = null;

if (await this._userRepository.UpdateAsync(userEntity, cancellationToken))
{
Expand All @@ -142,7 +142,7 @@ public async Task<MfaDeactivationResult> DeactivateMfaAsync(
return MfaDeactivationResult.InvalidCode;
}

public async Task<MfaInformation> GetMfaInformationAsync(
public async Task<MfaInformation?> GetMfaInformationAsync(
string emailAddress,
CancellationToken cancellationToken = default)
{
Expand All @@ -152,7 +152,7 @@ public async Task<MfaInformation> GetMfaInformationAsync(
return null;
}

if (userEntity.mfaActive)
if (userEntity.MfaActive)
{
return new MfaInformation
{
Expand All @@ -166,7 +166,7 @@ public async Task<MfaInformation> GetMfaInformationAsync(
}

var twoFactorAuthenticator = new TwoFactorAuthenticator();
var setupCode = twoFactorAuthenticator.GenerateSetupCode(this._issuer, emailAddress, userEntity.mfaSecret);
var setupCode = twoFactorAuthenticator.GenerateSetupCode(this._issuer, emailAddress, userEntity.MfaSecret);

return new MfaInformation
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public async Task<AuthenticationResult> ValidateCredentialsAsync(
var passwordHash = PasswordHelper.HashPasword(authenticationRequest.Password, userEntity.PasswordSalt);
if (userEntity.PasswordHash.SequenceEqual(passwordHash))
{
if (userEntity.mfaActive)
if (userEntity.MfaActive)
{
var mfaIdentifier = Guid.NewGuid().ToString();
var cacheKey = this.GetCacheKey(mfaIdentifier);
Expand Down Expand Up @@ -271,7 +271,7 @@ public async Task<ValidateTokenResult> ValidateTokenAsync(
}

var twoFactorAuthenticator = new TwoFactorAuthenticator();
var isTokenValid = twoFactorAuthenticator.ValidateTwoFactorPIN(userEntity.mfaSecret, token, timeTolerance);
var isTokenValid = twoFactorAuthenticator.ValidateTwoFactorPIN(userEntity.MfaSecret, token, timeTolerance);

return new ValidateTokenResult
{
Expand Down

0 comments on commit 41a6592

Please sign in to comment.