Module: BetterAuth

Defined in:
lib/better_auth.rb,
lib/better_auth/api.rb,
lib/better_auth/auth.rb,
lib/better_auth/core.rb,
lib/better_auth/error.rb,
lib/better_auth/crypto.rb,
lib/better_auth/plugin.rb,
lib/better_auth/router.rb,
lib/better_auth/schema.rb,
lib/better_auth/context.rb,
lib/better_auth/cookies.rb,
lib/better_auth/plugins.rb,
lib/better_auth/session.rb,
lib/better_auth/version.rb,
lib/better_auth/endpoint.rb,
lib/better_auth/password.rb,
lib/better_auth/api_error.rb,
lib/better_auth/routes/ok.rb,
lib/better_auth/crypto/jwe.rb,
lib/better_auth/request_ip.rb,
lib/better_auth/schema/sql.rb,
lib/better_auth/plugins/jwt.rb,
lib/better_auth/plugins/mcp.rb,
lib/better_auth/plugins/sso.rb,
lib/better_auth/routes/user.rb,
lib/better_auth/adapters/sql.rb,
lib/better_auth/plugins/expo.rb,
lib/better_auth/plugins/scim.rb,
lib/better_auth/plugins/siwe.rb,
lib/better_auth/rate_limiter.rb,
lib/better_auth/routes/error.rb,
lib/better_auth/adapters/base.rb,
lib/better_auth/configuration.rb,
lib/better_auth/plugins/admin.rb,
lib/better_auth/routes/social.rb,
lib/better_auth/session_store.rb,
lib/better_auth/adapters/mssql.rb,
lib/better_auth/adapters/mysql.rb,
lib/better_auth/database_hooks.rb,
lib/better_auth/plugin_context.rb,
lib/better_auth/plugins/access.rb,
lib/better_auth/plugins/bearer.rb,
lib/better_auth/plugins/stripe.rb,
lib/better_auth/routes/account.rb,
lib/better_auth/routes/session.rb,
lib/better_auth/routes/sign_in.rb,
lib/better_auth/routes/sign_up.rb,
lib/better_auth/adapters/memory.rb,
lib/better_auth/adapters/sqlite.rb,
lib/better_auth/plugin_registry.rb,
lib/better_auth/plugins/api_key.rb,
lib/better_auth/plugins/captcha.rb,
lib/better_auth/plugins/one_tap.rb,
lib/better_auth/plugins/passkey.rb,
lib/better_auth/routes/password.rb,
lib/better_auth/routes/sign_out.rb,
lib/better_auth/adapters/mongodb.rb,
lib/better_auth/plugins/open_api.rb,
lib/better_auth/plugins/username.rb,
lib/better_auth/adapters/postgres.rb,
lib/better_auth/plugins/anonymous.rb,
lib/better_auth/plugins/email_otp.rb,
lib/better_auth/plugins/magic_link.rb,
lib/better_auth/plugins/two_factor.rb,
lib/better_auth/plugins/oauth_proxy.rb,
lib/better_auth/plugins/admin/schema.rb,
lib/better_auth/plugins/organization.rb,
lib/better_auth/plugins/phone_number.rb,
lib/better_auth/plugins/generic_oauth.rb,
lib/better_auth/plugins/multi_session.rb,
lib/better_auth/plugins/oidc_provider.rb,
lib/better_auth/social_providers/base.rb,
lib/better_auth/plugins/custom_session.rb,
lib/better_auth/plugins/oauth_protocol.rb,
lib/better_auth/plugins/oauth_provider.rb,
lib/better_auth/plugins/one_time_token.rb,
lib/better_auth/social_providers/apple.rb,
lib/better_auth/middleware/origin_check.rb,
lib/better_auth/social_providers/github.rb,
lib/better_auth/social_providers/gitlab.rb,
lib/better_auth/social_providers/google.rb,
lib/better_auth/social_providers/discord.rb,
lib/better_auth/adapters/internal_adapter.rb,
lib/better_auth/plugins/additional_fields.rb,
lib/better_auth/plugins/have_i_been_pwned.rb,
lib/better_auth/plugins/last_login_method.rb,
lib/better_auth/routes/email_verification.rb,
lib/better_auth/plugins/organization/schema.rb,
lib/better_auth/plugins/device_authorization.rb,
lib/better_auth/social_providers/microsoft_entra_id.rb

Defined Under Namespace

Modules: Adapters, Cookies, Core, Crypto, Middleware, Password, Plugins, RequestIP, Routes, Schema, Session, SocialProviders Classes: API, APIError, Auth, Configuration, Context, DatabaseHooks, Endpoint, Error, Plugin, PluginContext, PluginRegistry, RateLimiter, Router, SessionStore

Constant Summary collapse

BASE_ERROR_CODES =
{
  "USER_NOT_FOUND" => "User not found",
  "FAILED_TO_CREATE_USER" => "Failed to create user",
  "FAILED_TO_CREATE_SESSION" => "Failed to create session",
  "FAILED_TO_UPDATE_USER" => "Failed to update user",
  "FAILED_TO_GET_SESSION" => "Failed to get session",
  "INVALID_PASSWORD" => "Invalid password",
  "INVALID_EMAIL" => "Invalid email",
  "INVALID_EMAIL_OR_PASSWORD" => "Invalid email or password",
  "SOCIAL_ACCOUNT_ALREADY_LINKED" => "Social account already linked",
  "PROVIDER_NOT_FOUND" => "Provider not found",
  "INVALID_TOKEN" => "Invalid token",
  "ID_TOKEN_NOT_SUPPORTED" => "id_token not supported",
  "FAILED_TO_GET_USER_INFO" => "Failed to get user info",
  "USER_EMAIL_NOT_FOUND" => "User email not found",
  "EMAIL_NOT_VERIFIED" => "Email not verified",
  "PASSWORD_TOO_SHORT" => "Password too short",
  "PASSWORD_TOO_LONG" => "Password too long",
  "USER_ALREADY_EXISTS" => "User already exists.",
  "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL" => "User already exists. Use another email.",
  "EMAIL_CAN_NOT_BE_UPDATED" => "Email can not be updated",
  "CREDENTIAL_ACCOUNT_NOT_FOUND" => "Credential account not found",
  "SESSION_EXPIRED" => "Session expired. Re-authenticate to perform this action.",
  "FAILED_TO_UNLINK_LAST_ACCOUNT" => "You can't unlink your last account",
  "ACCOUNT_NOT_FOUND" => "Account not found",
  "USER_ALREADY_HAS_PASSWORD" => "User already has a password. Provide that to delete the account.",
  "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED" => "Cross-site navigation login blocked. This request appears to be a CSRF attack.",
  "VERIFICATION_EMAIL_NOT_ENABLED" => "Verification email isn't enabled",
  "EMAIL_ALREADY_VERIFIED" => "Email is already verified",
  "EMAIL_MISMATCH" => "Email mismatch",
  "SESSION_NOT_FRESH" => "Session is not fresh",
  "LINKED_ACCOUNT_ALREADY_EXISTS" => "Linked account already exists",
  "INVALID_ORIGIN" => "Invalid origin",
  "INVALID_CALLBACK_URL" => "Invalid callbackURL",
  "INVALID_REDIRECT_URL" => "Invalid redirectURL",
  "INVALID_ERROR_CALLBACK_URL" => "Invalid errorCallbackURL",
  "INVALID_NEW_USER_CALLBACK_URL" => "Invalid newUserCallbackURL",
  "MISSING_OR_NULL_ORIGIN" => "Missing or null Origin",
  "CALLBACK_URL_REQUIRED" => "callbackURL is required",
  "FAILED_TO_CREATE_VERIFICATION" => "Unable to create verification",
  "FIELD_NOT_ALLOWED" => "Field not allowed to be set",
  "ASYNC_VALIDATION_NOT_SUPPORTED" => "Async validation is not supported",
  "VALIDATION_ERROR" => "Validation Error",
  "MISSING_FIELD" => "Field is required"
}.freeze
VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.auth(options = {}) ⇒ Object



91
92
93
# File 'lib/better_auth.rb', line 91

def self.auth(options = {})
  Auth.new(options)
end