Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Dec 6, 2023
1 parent 0d7a837 commit 1f0d4e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ private async Task<JwtSecurityToken> CreateTokenAsync(

var claims = new List<Claim>
{
new Claim(JwtRegisteredClaimNames.UniqueName, request.EmailAddress),
new Claim(JwtRegisteredClaimNames.Email, request.EmailAddress)
new(JwtRegisteredClaimNames.UniqueName, request.EmailAddress),
new(JwtRegisteredClaimNames.Email, request.EmailAddress)
};

if (!string.IsNullOrEmpty(userInfo.Firstname))
Expand Down
3 changes: 3 additions & 0 deletions src/Nager.Authentication/Helpers/InitialUserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Nager.Authentication.Helpers
{
/// <summary>
/// InitialUserHelper
/// </summary>
public static class InitialUserHelper
{
public static async Task CreateUsersAsync(
Expand Down
7 changes: 5 additions & 2 deletions src/Nager.Authentication/Helpers/PasswordHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace Nager.Authentication.Helpers
{
/// <summary>
/// PasswordHelper
/// </summary>
public static class PasswordHelper
{
private const int IterationCount = 10_000;
Expand Down Expand Up @@ -46,9 +49,9 @@ public static byte[] HashPasword(string password, byte[] salt)
/// <returns></returns>
public static string CreateRandomPassword(int length)
{
using var rngCryptoServiceProvider = new RNGCryptoServiceProvider();
using var randomNumberGenerator = RandomNumberGenerator.Create();
var tokenBuffer = new byte[length];
rngCryptoServiceProvider.GetBytes(tokenBuffer);
randomNumberGenerator.GetBytes(tokenBuffer);
return Convert.ToBase64String(tokenBuffer);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Nager.Authentication/Helpers/RoleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Nager.Authentication.Helpers
{
/// <summary>
/// RoleHelper
/// </summary>
public static class RoleHelper
{
public static char RoleSeperator = ',';
Expand Down

0 comments on commit 1f0d4e0

Please sign in to comment.