payload-auth-plugin-fix
Version:
Authentication plugin for Payload CMS
97 lines (84 loc) • 1.97 kB
JavaScript
// src/core/errors/consoleErrors.ts
class AuthError extends Error {
constructor(message, cause) {
super(message);
this.name = "PAYLOAD_AUTH_PLUGIN_ERROR";
this.message = message;
this.cause = cause;
this.stack = "";
}
}
class InvalidServerURL extends AuthError {
constructor() {
super("Missing or invalid server URL. Please set serverURL in your Payload config");
}
}
class InvalidProvider extends AuthError {
constructor() {
super("Invalid Provider");
}
}
class ProviderAlreadyExists extends AuthError {
constructor() {
super("Duplicate provider found");
}
}
class InvalidOAuthAlgorithm extends AuthError {
constructor() {
super("Invalid OAuth Algorithm. Plugin only support OIDC and OAuth2 algorithms");
}
}
class InvalidOAuthResource extends AuthError {
constructor() {
super("Invalid resource request. Check docs before initiating requests");
}
}
class MissingOrInvalidSession extends AuthError {
constructor() {
super("Missing or invalid session.");
}
}
class MissingOrInvalidParams extends AuthError {
constructor() {
super("Missing or invalid params");
}
}
class AuthenticationFailed extends AuthError {
constructor() {
super("Failed to authenticate");
}
}
class UserNotFound extends AuthError {
constructor() {
super("User not found");
}
}
class InvalidCredentials extends AuthError {
constructor() {
super("Invalid credentials");
}
}
class MissingUsersCollection extends AuthError {
constructor() {
super("Missing users collection");
}
}
class InvalidPasskeyRequest extends AuthError {
constructor() {
super("Invalid or missing request");
}
}
export {
UserNotFound,
ProviderAlreadyExists,
MissingUsersCollection,
MissingOrInvalidSession,
MissingOrInvalidParams,
InvalidServerURL,
InvalidProvider,
InvalidPasskeyRequest,
InvalidOAuthResource,
InvalidOAuthAlgorithm,
InvalidCredentials,
AuthenticationFailed
};