Skip to content

Commit

Permalink
optimize ValidationTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Jan 2, 2024
1 parent bffa851 commit 435137b
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 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 @@ -26,8 +26,8 @@ public class UserEntity
[MaxLength(32)]
public byte[]? PasswordHash { get; set; }

public DateTime LastValidationTimestamp { get; set; }
public DateTime? LastFailedValidationTimestamp { get; set; }

public DateTime LastSuccessfulValidationTimestamp { get; set; }
public DateTime? LastSuccessfulValidationTimestamp { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/Nager.Authentication.Abstraction/Models/UserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class UserInfo

public string? Lastname { get; set; }

public DateTime LastValidationTimestamp { get; set; }
public DateTime? LastFailedValidationTimestamp { get; set; }

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

<Version>1.1.0</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<ActionResult<UserInfoDto>> GetUserAsync(
Firstname = userInfo.Firstname,
Lastname = userInfo.Lastname,
Roles = userInfo.Roles,
LastValidationTimestamp = userInfo.LastValidationTimestamp,
LastFailedValidationTimestamp = userInfo.LastFailedValidationTimestamp,
LastSuccessfulValidationTimestamp = userInfo.LastSuccessfulValidationTimestamp
};

Expand Down Expand Up @@ -93,7 +93,7 @@ public async Task<ActionResult<UserInfoDto[]>> QueryUsersAsync(
Firstname = userInfo.Firstname,
Lastname = userInfo.Lastname,
Roles = userInfo.Roles,
LastValidationTimestamp = userInfo.LastValidationTimestamp,
LastFailedValidationTimestamp = userInfo.LastFailedValidationTimestamp,
LastSuccessfulValidationTimestamp = userInfo.LastSuccessfulValidationTimestamp
});

Expand Down
4 changes: 2 additions & 2 deletions src/Nager.Authentication.AspNet/Dtos/UserInfoDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class UserInfoDto

public string Lastname { get; set; }

public DateTime LastValidationTimestamp { get; set; }
public DateTime? LastFailedValidationTimestamp { get; set; }

public DateTime LastSuccessfulValidationTimestamp { get; set; }
public DateTime? LastSuccessfulValidationTimestamp { get; set; }
}
}
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>1.1.2</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Task<bool> SetLastValidationTimestampAsync(
return Task.FromResult(false);
}

item.LastValidationTimestamp = DateTime.UtcNow;
item.LastFailedValidationTimestamp = DateTime.UtcNow;

return Task.FromResult(true);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Nager.Authentication.UnitTest/RoleHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ namespace Nager.Authentication.UnitTest
public class RoleHelperTest
{
[TestMethod]
public async Task AddRoleToRoleData_RoleDataNull_Successful()
public void AddRoleToRoleData_RoleDataNull_Successful()
{
var roleData = RoleHelper.AddRoleToRoleData(null, "test");

Assert.AreEqual(roleData, "test");
}

[TestMethod]
public async Task AddRoleToRoleData_RoleDataStringEmpty_Successful()
public void AddRoleToRoleData_RoleDataStringEmpty_Successful()
{
var roleData = RoleHelper.AddRoleToRoleData(string.Empty, "test");

Assert.AreEqual(roleData, "test");
}

[TestMethod]
public async Task AddRoleToRoleData_DuplicateRoleTest_Successful()
public void AddRoleToRoleData_DuplicateRoleTest_Successful()
{
var roleData = RoleHelper.AddRoleToRoleData("test", "test");

Assert.AreEqual(roleData, "test");
}

[TestMethod]
public async Task AddRoleToRoleData_DuplicateRoleTestPascalCase_Successful()
public void AddRoleToRoleData_DuplicateRoleTestPascalCase_Successful()
{
var roleData = RoleHelper.AddRoleToRoleData("test", "Test");

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>1.1.2</Version>
<Version>1.2.0</Version>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
2 changes: 1 addition & 1 deletion src/Nager.Authentication/Services/UserManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private UserInfo MapUserInfo(UserEntity userEntity)
Firstname = userEntity.Firstname,
Lastname = userEntity.Lastname,
Roles = RoleHelper.GetRoles(userEntity.RolesData),
LastValidationTimestamp = userEntity.LastValidationTimestamp,
LastFailedValidationTimestamp = userEntity.LastFailedValidationTimestamp,
LastSuccessfulValidationTimestamp = userEntity.LastSuccessfulValidationTimestamp
};
}
Expand Down

0 comments on commit 435137b

Please sign in to comment.