feat(admin): show deployed app version
This commit is contained in:
@@ -92,7 +92,11 @@ public sealed class AuthController : ControllerBase
|
||||
string Plan,
|
||||
AccountEntitlements Entitlements,
|
||||
GoogleLinkDto? GoogleLink,
|
||||
MicrosoftLinkDto? MicrosoftLink);
|
||||
MicrosoftLinkDto? MicrosoftLink)
|
||||
{
|
||||
public string AppVersion { get; init; } = "unknown";
|
||||
public string? AppCommitSha { get; init; }
|
||||
}
|
||||
public sealed record PendingEmailChangeResult(string? PendingEmail, DateTimeOffset? RequestedAtUtc);
|
||||
private const int MaxAvatarBytes = 1_000_000;
|
||||
private static readonly HashSet<string> AllowedAvatarExtensions = new(StringComparer.OrdinalIgnoreCase)
|
||||
@@ -468,7 +472,8 @@ public sealed class AuthController : ControllerBase
|
||||
if (user is not null)
|
||||
{
|
||||
var roles = await _users.GetRolesAsync(user);
|
||||
return Ok(ToMeResult(user, roles));
|
||||
var isAdmin = roles.Contains("Admin", StringComparer.OrdinalIgnoreCase);
|
||||
return Ok(WithBuildMetadata(ToMeResult(user, roles), isAdmin));
|
||||
}
|
||||
|
||||
var email = User.FindFirstValue(ClaimTypes.Email) ?? User.FindFirstValue("email");
|
||||
@@ -480,7 +485,7 @@ public sealed class AuthController : ControllerBase
|
||||
? "microsoft"
|
||||
: "external";
|
||||
|
||||
return Ok(new MeResult(
|
||||
return Ok(WithBuildMetadata(new MeResult(
|
||||
Provider: provider,
|
||||
Id: sub,
|
||||
Email: email,
|
||||
@@ -495,7 +500,7 @@ public sealed class AuthController : ControllerBase
|
||||
Plan: "free",
|
||||
Entitlements: AccountPlans.ForRoles(Array.Empty<string>()),
|
||||
GoogleLink: provider == "google" ? new GoogleLinkDto(false, email, null) : null,
|
||||
MicrosoftLink: provider == "microsoft" ? new MicrosoftLinkDto(false, email, null) : null));
|
||||
MicrosoftLink: provider == "microsoft" ? new MicrosoftLinkDto(false, email, null) : null), false));
|
||||
}
|
||||
|
||||
[HttpPut("profile")]
|
||||
@@ -1195,4 +1200,15 @@ public sealed class AuthController : ControllerBase
|
||||
Email: user.MicrosoftEmail,
|
||||
LinkedAt: user.MicrosoftLinkedAt));
|
||||
}
|
||||
|
||||
private MeResult WithBuildMetadata(MeResult result, bool include)
|
||||
{
|
||||
if (!include) return result;
|
||||
|
||||
return result with
|
||||
{
|
||||
AppVersion = BuildMetadata.ResolveVersion(_cfg),
|
||||
AppCommitSha = BuildMetadata.Normalize(_cfg["App:CommitSha"]),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user