Compare commits
3 Commits
214654f696
...
732918de53
| Author | SHA1 | Date |
|---|---|---|
|
|
732918de53 | |
|
|
de2c345b46 | |
|
|
8e8ec873b2 |
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
namespace AyCode.Core.Helpers
|
||||
{
|
||||
public static class AcCharGenerator
|
||||
public static class AcCharsGenerator
|
||||
{
|
||||
public static readonly char[] Letters;
|
||||
public static readonly char[] Numbers;
|
||||
public static readonly char[] LettersAndNumbers;
|
||||
|
||||
static AcCharGenerator()
|
||||
static AcCharsGenerator()
|
||||
{
|
||||
//"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
|
||||
|
|
@ -23,6 +23,7 @@ namespace AyCode.Core.Helpers
|
|||
private static char[] GetRandomChars(int minLength, int maxLength) => GetRandomChars(LettersAndNumbers, minLength, maxLength);
|
||||
private static char[] GetRandomChars(char[] sourceChars, int minLength, int maxLength)
|
||||
{
|
||||
if (minLength < 1) throw new ArgumentOutOfRangeException(nameof(minLength), "must have length greater than or equal to 1");
|
||||
var random = new Random();
|
||||
return Enumerable.Repeat(sourceChars, random.Next(minLength, maxLength)).Select(s => s[random.Next(s.Length)]).ToArray();
|
||||
}
|
||||
|
|
@ -32,7 +33,7 @@ namespace AyCode.Core.Helpers
|
|||
return new string(GetRandomChars(AcConst.MinUserTokenLength, AcConst.MaxUserTokenLength));
|
||||
}
|
||||
|
||||
public static string NewPassword()
|
||||
public static string NewPassword(int minLength = AcConst.MinPasswordLength, int maxLength = AcConst.MaxPasswordLength)
|
||||
{
|
||||
return new string(GetRandomChars(AcConst.MinPasswordLength, AcConst.MaxPasswordLength));
|
||||
}
|
||||
|
|
@ -55,6 +55,8 @@ namespace AyCode.Database.DataLayers.Users
|
|||
=> GetAllModelDtoAsync<TUserModelDto, TUser>();
|
||||
|
||||
public Task<List<TUser>> GetUsersAsync() => SessionAsync(ctx => ctx.Users.ToList());
|
||||
//public Task<List<TUserModelDto>> GetUserEmails() => SessionAsync(ctx => ctx.Users.Select(x => new UserModelDtoEmail(x)).ToList());
|
||||
|
||||
|
||||
|
||||
public Task<bool> AddUserAsync(TUser user)
|
||||
|
|
|
|||
Loading…
Reference in New Issue