Compare commits
2 Commits
0351a2b4fa
...
a377ca2072
| Author | SHA1 | Date | |
|---|---|---|---|
|
a377ca2072
|
|||
|
623e7a5771
|
@@ -79,7 +79,7 @@ public class MagicSpellService(
|
||||
.FirstOrDefaultAsync();
|
||||
if (contact is null) throw new ArgumentException("Account has no contact method that can use");
|
||||
|
||||
var link = $"{configuration.GetValue<string>("BaseUrl")}/spells/{Uri.EscapeDataString(spell.Spell)}";
|
||||
var link = $"{configuration.GetValue<string>("SiteUrl")}/spells/{Uri.EscapeDataString(spell.Spell)}";
|
||||
|
||||
logger.LogInformation("Sending magic spell... {Link}", link);
|
||||
|
||||
@@ -251,12 +251,15 @@ public class MagicSpellService(
|
||||
|
||||
private static string _GenerateRandomString(int length)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var result = new char[length];
|
||||
using var rng = RandomNumberGenerator.Create();
|
||||
var randomBytes = new byte[length];
|
||||
rng.GetBytes(randomBytes);
|
||||
|
||||
var base64String = Convert.ToBase64String(randomBytes);
|
||||
|
||||
return base64String[..length];
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
var bytes = new byte[1];
|
||||
rng.GetBytes(bytes);
|
||||
result[i] = chars[bytes[0] % chars.Length];
|
||||
}
|
||||
return new string(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user