1macro_rules! define_codes {
8 ($($code:ident),* $(,)?) => {
9 $(
10 #[doc = concat!("The `", stringify!($code), "` error code.")]
11 pub const $code: &str = stringify!($code);
12 )*
13 };
14}
15
16define_codes! {
17 ACCESS_DENIED,
18 ACCESS_TOKEN_NOT_FOUND,
19 ACCOUNT_NOT_FOUND,
20 ACCOUNT_TEMPORARILY_LOCKED,
21 AMBIGUOUS_ACCOUNT,
22 ANONYMOUS_USERS_CANNOT_SIGN_IN_AGAIN_ANONYMOUSLY,
23 ASYNC_VALIDATION_NOT_SUPPORTED,
24 AUTHENTICATION_FAILED,
25 AUTHENTICATION_REQUIRED,
26 AUTHORIZATION_PENDING,
27 AUTH_CANCELLED,
28 BACKUP_CODES_NOT_ENABLED,
29 BAD_REQUEST,
30 BANNED_USER,
31 BODY_MUST_BE_AN_OBJECT,
32 CALLBACK_URL_REQUIRED,
33 CANNOT_DELETE_A_PRE_DEFINED_ROLE,
34 CHALLENGE_NOT_FOUND,
35 CHANGE_EMAIL_DISABLED,
36 COULD_NOT_CREATE_SESSION,
37 CREDENTIAL_ACCOUNT_NOT_FOUND,
38 CROSS_SITE_NAVIGATION_LOGIN_BLOCKED,
39 DELETE_ANONYMOUS_USER_DISABLED,
40 DEVICE_CODE_ALREADY_PROCESSED,
41 DEVICE_CODE_NOT_CLAIMED,
42 DYNAMIC_ACCESS_CONTROL_DISABLED,
43 EMAIL_ALREADY_VERIFIED,
44 EMAIL_CAN_NOT_BE_UPDATED,
45 EMAIL_MISMATCH,
46 EMAIL_NOT_VERIFIED,
47 EMAIL_PASSWORD_DISABLED,
48 EMAIL_PASSWORD_SIGN_UP_DISABLED,
49 EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION,
50 EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION,
51 EXPIRED_DEVICE_CODE,
52 EXPIRED_USER_CODE,
53 EXPIRES_IN_IS_TOO_LARGE,
54 EXPIRES_IN_IS_TOO_SMALL,
55 FAILED_TO_CREATE_SESSION,
56 FAILED_TO_CREATE_USER,
57 FAILED_TO_CREATE_VERIFICATION,
58 FAILED_TO_DELETE_ANONYMOUS_USER,
59 FAILED_TO_DELETE_ANONYMOUS_USER_SESSIONS,
60 FAILED_TO_GET_ACCESS_TOKEN,
61 FAILED_TO_GET_SESSION,
62 FAILED_TO_GET_USER_INFO,
63 FAILED_TO_INVALIDATE_TWO_FACTOR_CHALLENGE,
64 FAILED_TO_REFRESH_ACCESS_TOKEN,
65 FAILED_TO_RETRIEVE_INVITATION,
66 FAILED_TO_UNLINK_LAST_ACCOUNT,
67 FAILED_TO_UPDATE_API_KEY,
68 FAILED_TO_UPDATE_PASSKEY,
69 FAILED_TO_UPDATE_USER,
70 FAILED_TO_VERIFY_REGISTRATION,
71 FIELD_NOT_ALLOWED,
72 ID_TOKEN_NOT_SUPPORTED,
73 INSUFFICIENT_API_KEY_PERMISSIONS,
74 INTERNAL_SERVER_ERROR,
75 INVALID_API_KEY,
76 INVALID_API_KEY_GETTER_RETURN_TYPE,
77 INVALID_BACKUP_CODE,
78 INVALID_CALLBACK_URL,
79 INVALID_CODE,
80 INVALID_DEVICE_CODE,
81 INVALID_DEVICE_CODE_STATUS,
82 INVALID_DISPLAY_USERNAME,
83 INVALID_EMAIL,
84 INVALID_EMAIL_FORMAT,
85 INVALID_EMAIL_OR_PASSWORD,
86 INVALID_ERROR_CALLBACK_URL,
87 INVALID_METADATA_TYPE,
88 INVALID_NAME_LENGTH,
89 INVALID_NEW_USER_CALLBACK_URL,
90 INVALID_OAUTH_CONFIG,
91 INVALID_OAUTH_CONFIGURATION,
92 INVALID_ORIGIN,
93 INVALID_OTP,
94 INVALID_PASSWORD,
95 INVALID_PHONE_NUMBER,
96 INVALID_PHONE_NUMBER_OR_PASSWORD,
97 INVALID_PREFIX_LENGTH,
98 INVALID_REDIRECT_URL,
99 INVALID_REFERENCE_ID_FROM_API_KEY,
100 INVALID_REMAINING,
101 INVALID_RESOURCE,
102 INVALID_ROLE_TYPE,
103 INVALID_SESSION_TOKEN,
104 INVALID_TEAM_ID,
105 INVALID_TOKEN,
106 INVALID_TWO_FACTOR_COOKIE,
107 INVALID_USER,
108 INVALID_USERNAME,
109 INVALID_USERNAME_OR_PASSWORD,
110 INVALID_USER_CODE,
111 INVALID_USER_ID_FROM_API_KEY,
112 INVITATION_LIMIT_REACHED,
113 INVITATION_NOT_FOUND,
114 INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION,
115 ISSUER_MISMATCH,
116 ISSUER_MISSING,
117 KEY_DISABLED,
118 KEY_DISABLED_EXPIRATION,
119 KEY_EXPIRED,
120 KEY_NOT_FOUND,
121 KEY_NOT_RECOVERABLE,
122 LINKED_ACCOUNT_ALREADY_EXISTS,
123 LINKING_DIFFERENT_EMAILS_NOT_ALLOWED,
124 LINKING_FAILED,
125 LINKING_NOT_ALLOWED,
126 MEMBER_NOT_FOUND,
127 METADATA_DISABLED,
128 METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED,
129 MISSING_AC_INSTANCE,
130 MISSING_FIELD,
131 MISSING_OR_NULL_ORIGIN,
132 MISSING_RESPONSE,
133 MISSING_SECRET_KEY,
134 NAME_REQUIRED,
135 NOT_FOUND,
136 NO_ACTIVE_ORGANIZATION,
137 NO_DATA_TO_UPDATE,
138 NO_DEFAULT_API_KEY_CONFIGURATION_FOUND,
139 NO_VALUES_TO_UPDATE,
140 ORGANIZATION_ALREADY_EXISTS,
141 ORGANIZATION_DELETION_DISABLED,
142 ORGANIZATION_ID_REQUIRED,
143 ORGANIZATION_MEMBERSHIP_LIMIT_REACHED,
144 ORGANIZATION_NOT_FOUND,
145 ORGANIZATION_PLUGIN_REQUIRED,
146 ORGANIZATION_SLUG_ALREADY_TAKEN,
147 OTP_EXPIRED,
148 OTP_HAS_EXPIRED,
149 OTP_NOT_CONFIGURED,
150 OTP_NOT_ENABLED,
151 OTP_NOT_FOUND,
152 PASSKEY_NOT_FOUND,
153 PASSWORD_ALREADY_SET,
154 PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER,
155 PASSWORD_COMPROMISED,
156 PASSWORD_TOO_LONG,
157 PASSWORD_TOO_SHORT,
158 PHONE_NUMBER_CANNOT_BE_UPDATED,
159 PHONE_NUMBER_EXIST,
160 PHONE_NUMBER_NOT_EXIST,
161 PHONE_NUMBER_NOT_VERIFIED,
162 POLLING_TOO_FREQUENTLY,
163 POPUP_BLOCKED,
164 POPUP_CLOSED,
165 POPUP_SIGN_IN_FAILED,
166 POPUP_TIMEOUT,
167 PREVIOUSLY_REGISTERED,
168 PROVIDER_CONFIG_NOT_FOUND,
169 PROVIDER_ID_REQUIRED,
170 PROVIDER_NOT_CONFIGURED,
171 PROVIDER_NOT_FOUND,
172 RATE_LIMITED,
173 RATE_LIMIT_EXCEEDED,
174 REFILL_AMOUNT_AND_INTERVAL_REQUIRED,
175 REFILL_INTERVAL_AND_AMOUNT_REQUIRED,
176 REFRESH_TOKEN_NOT_FOUND,
177 REGISTRATION_CANCELLED,
178 RESET_PASSWORD_DISABLED,
179 RESOLVED_USER_INVALID,
180 RESOLVE_USER_REQUIRED,
181 ROLE_IS_ASSIGNED_TO_MEMBERS,
182 ROLE_NAME_IS_ALREADY_TAKEN,
183 ROLE_NOT_FOUND,
184 SEND_OTP_NOT_IMPLEMENTED,
185 SERVER_ONLY_PROPERTY,
186 SERVICE_UNAVAILABLE,
187 SESSION_EXPIRED,
188 SESSION_NOT_FRESH,
189 SESSION_REQUIRED,
190 SIWE_INVALID_NONCE,
191 SOCIAL_ACCOUNT_ALREADY_LINKED,
192 TEAMS_DISABLED,
193 TEAM_ALREADY_EXISTS,
194 TEAM_MEMBER_LIMIT_REACHED,
195 TEAM_NOT_FOUND,
196 TOKEN_EXPIRED,
197 TOKEN_REFRESH_NOT_SUPPORTED,
198 TOKEN_URL_NOT_FOUND,
199 TOO_MANY_ATTEMPTS,
200 TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE,
201 TOO_MANY_ROLES,
202 TOTP_ALREADY_ENABLED,
203 TOTP_NOT_CONFIGURED,
204 TOTP_NOT_ENABLED,
205 TWO_FACTOR_NOT_ENABLED,
206 UNABLE_TO_CREATE_SESSION,
207 UNABLE_TO_REMOVE_LAST_TEAM,
208 UNAUTHORIZED,
209 UNAUTHORIZED_INVALID_OR_EXPIRED_NONCE,
210 UNAUTHORIZED_SESSION,
211 UNAUTHORIZED_SIWE_MESSAGE_EXPIRED,
212 UNAUTHORIZED_SIWE_MESSAGE_MISMATCH,
213 UNAUTHORIZED_SIWE_MESSAGE_NOT_YET_VALID,
214 UNEXPECTED_ERROR,
215 UNKNOWN_ERROR,
216 UNSUPPORTED_MEDIA_TYPE,
217 USAGE_EXCEEDED,
218 USERNAME_IS_ALREADY_TAKEN,
219 USERNAME_IS_IMMUTABLE,
220 USERNAME_TOO_LONG,
221 USERNAME_TOO_SHORT,
222 USER_ALREADY_EXISTS,
223 USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL,
224 USER_ALREADY_HAS_PASSWORD,
225 USER_BANNED,
226 USER_EMAIL_NOT_FOUND,
227 USER_ID_OR_SESSION_REQUIRED,
228 USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION,
229 USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION,
230 USER_IS_NOT_ANONYMOUS,
231 USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION,
232 USER_IS_NOT_A_MEMBER_OF_THE_TEAM,
233 USER_NOT_FOUND,
234 USER_NOT_MEMBER_OF_ORGANIZATION,
235 VALIDATION_ERROR,
236 VERIFICATION_EMAIL_NOT_ENABLED,
237 VERIFICATION_FAILED,
238 YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION,
239 YOU_ARE_NOT_ALLOWED_TO_BAN_USERS,
240 YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION,
241 YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE,
242 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION,
243 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM,
244 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER,
245 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE,
246 YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION,
247 YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS,
248 YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE,
249 YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION,
250 YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER,
251 YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION,
252 YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM,
253 YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS,
254 YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE,
255 YOU_ARE_NOT_ALLOWED_TO_GET_USER,
256 YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS,
257 YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION,
258 YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE,
259 YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE,
260 YOU_ARE_NOT_ALLOWED_TO_LIST_USERS,
261 YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS,
262 YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE,
263 YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY,
264 YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER,
265 YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS,
266 YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE,
267 YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL,
268 YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD,
269 YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE,
270 YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER,
271 YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION,
272 YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM,
273 YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS,
274 YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION,
275 YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION,
276 YOU_CANNOT_BAN_YOURSELF,
277 YOU_CANNOT_IMPERSONATE_ADMINS,
278 YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER,
279 YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER,
280 YOU_CANNOT_REMOVE_YOURSELF,
281 YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM,
282 YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM,
283 YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS,
284 YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS,
285 YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE,
286}
287
288pub(in crate::error) const UPSTREAM_ERROR_CODES: &[(&str, &str)] = &[
290 (
291 "API Key getter returned an invalid key type. Expected string.",
292 INVALID_API_KEY_GETTER_RETURN_TYPE,
293 ),
294 ("API Key has expired", KEY_EXPIRED),
295 ("API Key has reached its usage limit", USAGE_EXCEEDED),
296 ("API Key is disabled", KEY_DISABLED),
297 ("API Key is not recoverable", KEY_NOT_RECOVERABLE),
298 ("API Key name is required.", NAME_REQUIRED),
299 ("API Key not found", KEY_NOT_FOUND),
300 ("Access denied", ACCESS_DENIED),
301 ("Access token not found", ACCESS_TOKEN_NOT_FOUND),
302 (
303 "Account is not associated with a configured social provider.",
304 PROVIDER_NOT_CONFIGURED,
305 ),
306 ("Account not found", ACCOUNT_NOT_FOUND),
307 (
308 "Account not linked - different emails not allowed",
309 LINKING_DIFFERENT_EMAILS_NOT_ALLOWED,
310 ),
311 (
312 "Account not linked - linking not allowed",
313 LINKING_NOT_ALLOWED,
314 ),
315 (
316 "Account not linked - unable to create account",
317 LINKING_FAILED,
318 ),
319 (
320 "Anonymous users cannot sign in again anonymously",
321 ANONYMOUS_USERS_CANNOT_SIGN_IN_AGAIN_ANONYMOUSLY,
322 ),
323 (
324 "Async validation is not supported",
325 ASYNC_VALIDATION_NOT_SUPPORTED,
326 ),
327 ("Auth cancelled", AUTH_CANCELLED),
328 ("Authentication failed", AUTHENTICATION_FAILED),
329 ("Authentication required", AUTHENTICATION_REQUIRED),
330 ("Authorization pending", AUTHORIZATION_PENDING),
331 ("Backup codes aren't enabled", BACKUP_CODES_NOT_ENABLED),
332 ("Body must be an object", BODY_MUST_BE_AN_OBJECT),
333 ("CAPTCHA service unavailable", SERVICE_UNAVAILABLE),
334 (
335 "Cannot delete a pre-defined role",
336 CANNOT_DELETE_A_PRE_DEFINED_ROLE,
337 ),
338 (
339 "Cannot delete a role that is assigned to members. Please reassign the members to a different role first",
340 ROLE_IS_ASSIGNED_TO_MEMBERS,
341 ),
342 ("Captcha verification failed", VERIFICATION_FAILED),
343 ("Challenge not found", CHALLENGE_NOT_FOUND),
344 ("Change email is disabled", CHANGE_EMAIL_DISABLED),
345 ("Could not create session", COULD_NOT_CREATE_SESSION),
346 ("Credential account not found", CREDENTIAL_ACCOUNT_NOT_FOUND),
347 (
348 "Cross-site navigation login blocked. This request appears to be a CSRF attack.",
349 CROSS_SITE_NAVIGATION_LOGIN_BLOCKED,
350 ),
351 (
352 "Custom key expiration values are disabled.",
353 KEY_DISABLED_EXPIRATION,
354 ),
355 (
356 "Deleting anonymous users is disabled",
357 DELETE_ANONYMOUS_USER_DISABLED,
358 ),
359 (
360 "Device code already processed",
361 DEVICE_CODE_ALREADY_PROCESSED,
362 ),
363 ("Device code has expired", EXPIRED_DEVICE_CODE),
364 (
365 "Device code has not been claimed by a verifying session; call `GET /device` with the `user_code` while signed in before approving or denying",
366 DEVICE_CODE_NOT_CLAIMED,
367 ),
368 ("Display username is invalid", INVALID_DISPLAY_USERNAME),
369 (
370 "Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information",
371 MISSING_AC_INSTANCE,
372 ),
373 (
374 "Either userId or session is required",
375 USER_ID_OR_SESSION_REQUIRED,
376 ),
377 ("Email and password is not enabled", EMAIL_PASSWORD_DISABLED),
378 (
379 "Email and password sign up is not enabled",
380 EMAIL_PASSWORD_SIGN_UP_DISABLED,
381 ),
382 ("Email can not be updated", EMAIL_CAN_NOT_BE_UPDATED),
383 ("Email is already verified", EMAIL_ALREADY_VERIFIED),
384 ("Email mismatch", EMAIL_MISMATCH),
385 ("Email not verified", EMAIL_NOT_VERIFIED),
386 (
387 "Email verification required before accepting or rejecting invitation",
388 EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION,
389 ),
390 (
391 "Email verification required to view or list invitations for the session email",
392 EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION,
393 ),
394 (
395 "Email was not generated in a valid format",
396 INVALID_EMAIL_FORMAT,
397 ),
398 ("Failed to create session", FAILED_TO_CREATE_SESSION),
399 ("Failed to create user", FAILED_TO_CREATE_USER),
400 (
401 "Failed to delete anonymous user",
402 FAILED_TO_DELETE_ANONYMOUS_USER,
403 ),
404 (
405 "Failed to delete anonymous user sessions",
406 FAILED_TO_DELETE_ANONYMOUS_USER_SESSIONS,
407 ),
408 (
409 "Failed to get a valid access token",
410 FAILED_TO_GET_ACCESS_TOKEN,
411 ),
412 ("Failed to get session", FAILED_TO_GET_SESSION),
413 ("Failed to get user info", FAILED_TO_GET_USER_INFO),
414 (
415 "Failed to refresh access token",
416 FAILED_TO_REFRESH_ACCESS_TOKEN,
417 ),
418 (
419 "Failed to retrieve invitation",
420 FAILED_TO_RETRIEVE_INVITATION,
421 ),
422 ("Failed to update API key", FAILED_TO_UPDATE_API_KEY),
423 ("Failed to update passkey", FAILED_TO_UPDATE_PASSKEY),
424 ("Failed to update user", FAILED_TO_UPDATE_USER),
425 (
426 "Failed to verify registration",
427 FAILED_TO_VERIFY_REGISTRATION,
428 ),
429 ("Field is required", MISSING_FIELD),
430 ("Field not allowed to be set", FIELD_NOT_ALLOWED),
431 ("Internal Server Error", INTERNAL_SERVER_ERROR),
432 ("Invalid API key.", INVALID_API_KEY),
433 ("Invalid OAuth configuration", INVALID_OAUTH_CONFIGURATION),
434 ("Invalid OAuth configuration.", INVALID_OAUTH_CONFIG),
435 (
436 "Invalid OAuth configuration. Token URL not found.",
437 TOKEN_URL_NOT_FOUND,
438 ),
439 ("Invalid OTP", INVALID_OTP),
440 ("Invalid backup code", INVALID_BACKUP_CODE),
441 ("Invalid callbackURL", INVALID_CALLBACK_URL),
442 ("Invalid code", INVALID_CODE),
443 ("Invalid device code", INVALID_DEVICE_CODE),
444 ("Invalid device code status", INVALID_DEVICE_CODE_STATUS),
445 ("Invalid email", INVALID_EMAIL),
446 ("Invalid email or password", INVALID_EMAIL_OR_PASSWORD),
447 ("Invalid errorCallbackURL", INVALID_ERROR_CALLBACK_URL),
448 ("Invalid newUserCallbackURL", INVALID_NEW_USER_CALLBACK_URL),
449 ("Invalid origin", INVALID_ORIGIN),
450 ("Invalid password", INVALID_PASSWORD),
451 ("Invalid phone number", INVALID_PHONE_NUMBER),
452 (
453 "Invalid phone number or password",
454 INVALID_PHONE_NUMBER_OR_PASSWORD,
455 ),
456 ("Invalid redirectURL", INVALID_REDIRECT_URL),
457 ("Invalid role type", INVALID_ROLE_TYPE),
458 ("Invalid token", INVALID_TOKEN),
459 ("Invalid two factor cookie", INVALID_TWO_FACTOR_COOKIE),
460 ("Invalid user", INVALID_USER),
461 ("Invalid user code", INVALID_USER_CODE),
462 ("Invalid username or password", INVALID_USERNAME_OR_PASSWORD),
463 ("Invitation limit reached", INVITATION_LIMIT_REACHED),
464 ("Invitation not found", INVITATION_NOT_FOUND),
465 ("Invitation not found!", INVITATION_NOT_FOUND),
466 (
467 "Inviter is no longer a member of the organization",
468 INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION,
469 ),
470 (
471 "Linked account already exists",
472 LINKED_ACCOUNT_ALREADY_EXISTS,
473 ),
474 ("Member not found", MEMBER_NOT_FOUND),
475 ("Metadata is disabled.", METADATA_DISABLED),
476 ("Missing CAPTCHA response", MISSING_RESPONSE),
477 ("Missing or null Origin", MISSING_OR_NULL_ORIGIN),
478 ("Missing secret key", MISSING_SECRET_KEY),
479 (
480 "Multiple accounts share this account ID. Pass a providerId to disambiguate.",
481 AMBIGUOUS_ACCOUNT,
482 ),
483 ("No active organization", NO_ACTIVE_ORGANIZATION),
484 ("No config found for provider", PROVIDER_CONFIG_NOT_FOUND),
485 ("No data to update", NO_DATA_TO_UPDATE),
486 (
487 "No default api-key configuration found.",
488 NO_DEFAULT_API_KEY_CONFIGURATION_FOUND,
489 ),
490 ("No values to update.", NO_VALUES_TO_UPDATE),
491 ("Not found", NOT_FOUND),
492 (
493 "OAuth issuer mismatch. The authorization server issuer does not match the expected value (RFC 9207).",
494 ISSUER_MISMATCH,
495 ),
496 (
497 "OAuth issuer parameter missing. The authorization server did not include the required iss parameter (RFC 9207).",
498 ISSUER_MISSING,
499 ),
500 ("OTP expired", OTP_EXPIRED),
501 ("OTP has expired", OTP_HAS_EXPIRED),
502 ("OTP not enabled", OTP_NOT_ENABLED),
503 ("OTP not found", OTP_NOT_FOUND),
504 (
505 "Organization ID is required for organization-owned API keys.",
506 ORGANIZATION_ID_REQUIRED,
507 ),
508 ("Organization already exists", ORGANIZATION_ALREADY_EXISTS),
509 (
510 "Organization deletion is disabled",
511 ORGANIZATION_DELETION_DISABLED,
512 ),
513 (
514 "Organization membership limit reached",
515 ORGANIZATION_MEMBERSHIP_LIMIT_REACHED,
516 ),
517 ("Organization not found", ORGANIZATION_NOT_FOUND),
518 (
519 "Organization plugin is required for organization-owned API keys. Please install and configure the organization plugin.",
520 ORGANIZATION_PLUGIN_REQUIRED,
521 ),
522 (
523 "Organization slug already taken",
524 ORGANIZATION_SLUG_ALREADY_TAKEN,
525 ),
526 (
527 "POST method requires deferSessionRefresh to be enabled in session config",
528 METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED,
529 ),
530 ("Passkey not found", PASSKEY_NOT_FOUND),
531 (
532 "Passkey registration requires an authenticated session",
533 SESSION_REQUIRED,
534 ),
535 (
536 "Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false",
537 RESOLVE_USER_REQUIRED,
538 ),
539 (
540 "Password cannot be updated through update-user. Use the set-user-password endpoint instead",
541 PASSWORD_CANNOT_BE_UPDATED_VIA_UPDATE_USER,
542 ),
543 ("Password too long", PASSWORD_TOO_LONG),
544 ("Password too short", PASSWORD_TOO_SHORT),
545 ("Phone number already exists", PHONE_NUMBER_EXIST),
546 (
547 "Phone number cannot be updated",
548 PHONE_NUMBER_CANNOT_BE_UPDATED,
549 ),
550 ("Phone number not verified", PHONE_NUMBER_NOT_VERIFIED),
551 ("Polling too frequently", POLLING_TOO_FREQUENTLY),
552 ("Popup sign-in failed", POPUP_SIGN_IN_FAILED),
553 ("Previously registered", PREVIOUSLY_REGISTERED),
554 ("Provider ID is required", PROVIDER_ID_REQUIRED),
555 ("Provider not found", PROVIDER_NOT_FOUND),
556 ("Rate limit exceeded.", RATE_LIMIT_EXCEEDED),
557 ("Refresh token not found", REFRESH_TOKEN_NOT_FOUND),
558 ("Registration cancelled", REGISTRATION_CANCELLED),
559 ("Reset password isn't enabled", RESET_PASSWORD_DISABLED),
560 ("Resolved user is invalid", RESOLVED_USER_INVALID),
561 ("Role not found", ROLE_NOT_FOUND),
562 (
563 "Session expired. Re-authenticate to perform this action.",
564 SESSION_EXPIRED,
565 ),
566 ("Session is not fresh", SESSION_NOT_FRESH),
567 ("Session is required", SESSION_REQUIRED),
568 ("Sign-in popup timed out", POPUP_TIMEOUT),
569 ("Sign-in popup was blocked by the browser", POPUP_BLOCKED),
570 ("Sign-in popup was closed before completing", POPUP_CLOSED),
571 (
572 "Social account already linked",
573 SOCIAL_ACCOUNT_ALREADY_LINKED,
574 ),
575 ("Something went wrong", UNKNOWN_ERROR),
576 ("TOTP not enabled", TOTP_NOT_ENABLED),
577 ("Team already exists", TEAM_ALREADY_EXISTS),
578 ("Team id contains a reserved character", INVALID_TEAM_ID),
579 ("Team member limit reached", TEAM_MEMBER_LIMIT_REACHED),
580 ("Team not found", TEAM_NOT_FOUND),
581 (
582 "That role name is already taken",
583 ROLE_NAME_IS_ALREADY_TAKEN,
584 ),
585 (
586 "The expiresIn is larger than the predefined maximum value.",
587 EXPIRES_IN_IS_TOO_LARGE,
588 ),
589 (
590 "The expiresIn is smaller than the predefined minimum value.",
591 EXPIRES_IN_IS_TOO_SMALL,
592 ),
593 (
594 "The name length is either too large or too small.",
595 INVALID_NAME_LENGTH,
596 ),
597 (
598 "The prefix length is either too large or too small.",
599 INVALID_PREFIX_LENGTH,
600 ),
601 (
602 "The property you're trying to set can only be set from the server auth instance only.",
603 SERVER_ONLY_PROPERTY,
604 ),
605 (
606 "The provided permission includes an invalid resource",
607 INVALID_RESOURCE,
608 ),
609 (
610 "The reference id from the API key is invalid.",
611 INVALID_REFERENCE_ID_FROM_API_KEY,
612 ),
613 (
614 "The remaining count is either too large or too small.",
615 INVALID_REMAINING,
616 ),
617 (
618 "The user id from the API key is invalid.",
619 INVALID_USER_ID_FROM_API_KEY,
620 ),
621 ("This organization has too many roles", TOO_MANY_ROLES),
622 ("Token expired", TOKEN_EXPIRED),
623 ("Too many attempts", TOO_MANY_ATTEMPTS),
624 (
625 "Too many attempts. Please request a new code.",
626 TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE,
627 ),
628 (
629 "Too many failed verification attempts. Your account is temporarily locked. Please try again later.",
630 ACCOUNT_TEMPORARILY_LOCKED,
631 ),
632 ("Two factor isn't enabled", TWO_FACTOR_NOT_ENABLED),
633 ("Unable to create session", UNABLE_TO_CREATE_SESSION),
634 (
635 "Unable to create verification",
636 FAILED_TO_CREATE_VERIFICATION,
637 ),
638 ("Unable to remove last team", UNABLE_TO_REMOVE_LAST_TEAM),
639 ("Unauthorized", UNAUTHORIZED),
640 ("Unauthorized or invalid session", UNAUTHORIZED_SESSION),
641 ("Unexpected error", UNEXPECTED_ERROR),
642 ("Unknown error", UNKNOWN_ERROR),
643 ("User already exists.", USER_ALREADY_EXISTS),
644 (
645 "User already exists. Use another email.",
646 USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL,
647 ),
648 ("User already has a password set", PASSWORD_ALREADY_SET),
649 (
650 "User already has a password. Provide that to delete the account.",
651 USER_ALREADY_HAS_PASSWORD,
652 ),
653 ("User code has expired", EXPIRED_USER_CODE),
654 ("User email not found", USER_EMAIL_NOT_FOUND),
655 (
656 "User is already a member of this organization",
657 USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION,
658 ),
659 (
660 "User is already invited to this organization",
661 USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION,
662 ),
663 ("User is banned", USER_BANNED),
664 (
665 "User is not a member of the organization",
666 USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION,
667 ),
668 (
669 "User is not a member of the team",
670 USER_IS_NOT_A_MEMBER_OF_THE_TEAM,
671 ),
672 ("User is not anonymous", USER_IS_NOT_ANONYMOUS),
673 ("User not found", USER_NOT_FOUND),
674 (
675 "Username is already taken. Please try another.",
676 USERNAME_IS_ALREADY_TAKEN,
677 ),
678 ("Username is invalid", INVALID_USERNAME),
679 ("Username is too long", USERNAME_TOO_LONG),
680 ("Username is too short", USERNAME_TOO_SHORT),
681 ("Validation Error", VALIDATION_ERROR),
682 (
683 "Verification email isn't enabled",
684 VERIFICATION_EMAIL_NOT_ENABLED,
685 ),
686 (
687 "You are not a member of the organization that owns this API key.",
688 USER_NOT_MEMBER_OF_ORGANIZATION,
689 ),
690 (
691 "You are not a member of this organization",
692 YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION,
693 ),
694 (
695 "You are not allowed to access this organization as an owner",
696 YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION,
697 ),
698 (
699 "You are not allowed to ban users",
700 YOU_ARE_NOT_ALLOWED_TO_BAN_USERS,
701 ),
702 (
703 "You are not allowed to cancel this invitation",
704 YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION,
705 ),
706 (
707 "You are not allowed to change users role",
708 YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE,
709 ),
710 (
711 "You are not allowed to create a new member",
712 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER,
713 ),
714 (
715 "You are not allowed to create a new organization",
716 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION,
717 ),
718 (
719 "You are not allowed to create a new team",
720 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM,
721 ),
722 (
723 "You are not allowed to create a role",
724 YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE,
725 ),
726 (
727 "You are not allowed to create teams in this organization",
728 YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION,
729 ),
730 (
731 "You are not allowed to create users",
732 YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS,
733 ),
734 (
735 "You are not allowed to delete a role",
736 YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE,
737 ),
738 (
739 "You are not allowed to delete teams in this organization",
740 YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION,
741 ),
742 (
743 "You are not allowed to delete this member",
744 YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER,
745 ),
746 (
747 "You are not allowed to delete this organization",
748 YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION,
749 ),
750 (
751 "You are not allowed to delete this team",
752 YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM,
753 ),
754 (
755 "You are not allowed to delete users",
756 YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS,
757 ),
758 (
759 "You are not allowed to get a role",
760 YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE,
761 ),
762 (
763 "You are not allowed to get user",
764 YOU_ARE_NOT_ALLOWED_TO_GET_USER,
765 ),
766 (
767 "You are not allowed to impersonate users",
768 YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS,
769 ),
770 (
771 "You are not allowed to invite a user with this role",
772 YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE,
773 ),
774 (
775 "You are not allowed to invite users to this organization",
776 YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION,
777 ),
778 (
779 "You are not allowed to list a role",
780 YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE,
781 ),
782 (
783 "You are not allowed to list the members of this team",
784 YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM,
785 ),
786 (
787 "You are not allowed to list users",
788 YOU_ARE_NOT_ALLOWED_TO_LIST_USERS,
789 ),
790 (
791 "You are not allowed to list users sessions",
792 YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS,
793 ),
794 (
795 "You are not allowed to read a role",
796 YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE,
797 ),
798 (
799 "You are not allowed to register this passkey",
800 YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY,
801 ),
802 (
803 "You are not allowed to remove a team member",
804 YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER,
805 ),
806 (
807 "You are not allowed to revoke users sessions",
808 YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS,
809 ),
810 (
811 "You are not allowed to set a non-existent role value",
812 YOU_ARE_NOT_ALLOWED_TO_SET_NON_EXISTENT_VALUE,
813 ),
814 (
815 "You are not allowed to set users password",
816 YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD,
817 ),
818 (
819 "You are not allowed to update a role",
820 YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE,
821 ),
822 (
823 "You are not allowed to update this member",
824 YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER,
825 ),
826 (
827 "You are not allowed to update this organization",
828 YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION,
829 ),
830 (
831 "You are not allowed to update this team",
832 YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM,
833 ),
834 (
835 "You are not allowed to update users",
836 YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS,
837 ),
838 (
839 "You are not allowed to update users email",
840 YOU_ARE_NOT_ALLOWED_TO_SET_USERS_EMAIL,
841 ),
842 (
843 "You are not the recipient of the invitation",
844 YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION,
845 ),
846 (
847 "You can't unlink your last account",
848 FAILED_TO_UNLINK_LAST_ACCOUNT,
849 ),
850 ("You cannot ban yourself", YOU_CANNOT_BAN_YOURSELF),
851 (
852 "You cannot impersonate admins",
853 YOU_CANNOT_IMPERSONATE_ADMINS,
854 ),
855 (
856 "You cannot leave the organization as the only owner",
857 YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER,
858 ),
859 (
860 "You cannot leave the organization without an owner",
861 YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER,
862 ),
863 ("You cannot remove yourself", YOU_CANNOT_REMOVE_YOURSELF),
864 (
865 "You do not have an active team",
866 YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM,
867 ),
868 (
869 "You do not have permission to perform this action on organization API keys.",
870 INSUFFICIENT_API_KEY_PERMISSIONS,
871 ),
872 ("You have been banned from this application", BANNED_USER),
873 (
874 "You have reached the maximum number of organizations",
875 YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS,
876 ),
877 (
878 "You have reached the maximum number of teams",
879 YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS,
880 ),
881 (
882 "You must be in an organization to create a role",
883 YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE,
884 ),
885 ("callbackURL is required", CALLBACK_URL_REQUIRED),
886 ("failed to create session", FAILED_TO_CREATE_SESSION),
887 ("id_token not supported", ID_TOKEN_NOT_SUPPORTED),
888 (
889 "metadata must be an object or undefined",
890 INVALID_METADATA_TYPE,
891 ),
892 ("otp isn't configured", OTP_NOT_CONFIGURED),
893 ("phone number isn't registered", PHONE_NUMBER_NOT_EXIST),
894 (
895 "refillAmount is required when refillInterval is provided",
896 REFILL_AMOUNT_AND_INTERVAL_REQUIRED,
897 ),
898 (
899 "refillInterval is required when refillAmount is provided",
900 REFILL_INTERVAL_AND_AMOUNT_REQUIRED,
901 ),
902 ("sendOTP not implemented", SEND_OTP_NOT_IMPLEMENTED),
903 ("totp isn't configured", TOTP_NOT_CONFIGURED),
904];
905
906pub(in crate::error) fn upstream_code(message: &str) -> Option<&'static str> {
907 UPSTREAM_ERROR_CODES
908 .binary_search_by_key(&message, |(candidate, _)| candidate)
909 .ok()
910 .and_then(|index| UPSTREAM_ERROR_CODES.get(index))
911 .map(|(_, code)| *code)
912}