Skip to content

Commit 076420b

Browse files
jrmccannonTyrrrz
andauthored
Allow AC to send magic links (#507)
* Added check for admin console. Co-authored-by: Oleksii Holub <[email protected]>
1 parent c4058bb commit 076420b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Service/MagicLinks/MagicLinkService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Microsoft.Extensions.Caching.Memory;
21
using Passwordless.Common.MagicLinks.Models;
32
using Passwordless.Common.Services.Mail;
43
using Passwordless.Service.EventLog.Loggers;
@@ -10,7 +9,6 @@ namespace Passwordless.Service.MagicLinks;
109

1110
public class MagicLinkService(
1211
TimeProvider timeProvider,
13-
IMemoryCache cache,
1412
ITenantStorage tenantStorage,
1513
IFido2Service fido2Service,
1614
IMailProvider mailProvider,
@@ -24,6 +22,7 @@ private async Task EnforceQuotaAsync(MagicLinkTokenRequest request)
2422

2523
// Applications created less than 24 hours ago can only send magic links to the admin email address
2624
if (accountAge < TimeSpan.FromHours(24) &&
25+
!IsAdminConsole(account) &&
2726
!account.AdminEmails.Contains(request.EmailAddress.Address, StringComparer.OrdinalIgnoreCase))
2827
{
2928
throw new ApiException(
@@ -64,6 +63,10 @@ private async Task EnforceQuotaAsync(MagicLinkTokenRequest request)
6463
}
6564
}
6665

66+
private static bool IsAdminConsole(PerTenant account) =>
67+
string.Equals(account.Tenant, "admin", StringComparison.OrdinalIgnoreCase)
68+
|| string.Equals(account.Tenant, "adminconsole", StringComparison.OrdinalIgnoreCase);
69+
6770
public async Task SendMagicLinkAsync(MagicLinkTokenRequest request)
6871
{
6972
await EnforceQuotaAsync(request);

0 commit comments

Comments
 (0)