Files
tiku-backend.net/Tiku.Application/Auth/AuthExceptions.cs
xiong c497a3ca8d
Some checks failed
ci / release-gate (push) Has been cancelled
清理代码
2026-08-03 12:31:39 +08:00

34 lines
1.6 KiB
C#

namespace Tiku.Application.Auth;
public class AuthException(string code, string message) : Exception(message)
{
public string Code { get; } = code;
}
public sealed class InvalidCredentialsException(string code = "invalid_credentials")
: AuthException(code, "The supplied credentials are invalid.");
public sealed class TenantAccessDeniedException()
: AuthException("tenant_access_denied", "The user is not an active member of the requested tenant.");
public sealed class SessionRevokedException()
: AuthException("session_revoked", "The session has been revoked or expired.");
public sealed class SmsRateLimitedException()
: AuthException("sms_rate_limited", "SMS verification requests are rate limited.");
public sealed class AuthProviderNotConfiguredException(string provider)
: AuthException("auth_provider_not_configured", $"The {provider} auth provider is not configured.");
public sealed class AuthSecurityUnavailableException()
: AuthException("auth_security_unavailable", "Authentication security services are unavailable.");
public sealed class InvalidAuthChallengeException(string code = "invalid_auth_challenge")
: AuthException(code, "The authentication challenge is invalid, consumed, or expired.");
public sealed class AuthSessionNotFoundException()
: AuthException("auth_session_not_found", "The requested authentication session was not found.");
public sealed class CurrentAuthSessionCannotBeRevokedException()
: AuthException("current_auth_session_cannot_be_revoked",
"Use logout to revoke the current authentication session.");