devise-token-auth
  • Installation
  • Configuration
    • Initializer Settings
    • OmniAuth
    • Email Authentication
    • Customizing Devise Verbiage
    • Cross Origin Requests (CORS)
  • Usage
    • Mounting Routes
    • Controller Integration
    • Model Integration
    • Using Multiple User Classes
    • Excluding Modules
    • Custom Controller/Email Overrides
    • Reset password flow
    • Testing
  • FAQ
  • Conceptual Diagrams
    • Token Management
    • Batch Requests
  • Security
Powered by GitBook
On this page

Configuration

PreviousInstallationNextInitializer Settings

Last updated 7 years ago

You will need to create a , , , and you may want to alter some of the for this gem. Run the following command for an easy one-step installation:

rails g devise_token_auth:install [USER_CLASS] [MOUNT_PATH]

or for Mongoid

rails g devise_token_auth:install_mongoid [USER_CLASS] [MOUNT_PATH]

Example:

rails g devise_token_auth:install User auth

This generator accepts the following optional arguments:

Argument

Default

Description

USER_CLASS

User

The name of the class to use for user authentication.

MOUNT_PATH

auth

The following events will take place when using the install generator:

  • An initializer will be created at config/initializers/devise_token_auth.rb. .

  • A model will be created in the app/models directory. If the model already exists, a concern (and fields for Mongoid) will be included at the file. .

  • Routes will be appended to file at config/routes.rb. .

  • A concern will be included by your application controller at app/controllers/application_controller.rb. .

  • For ActiveRecord a migration file will be created in the db/migrate directory. Inspect the migrations file, add additional columns if necessary, and then run the migration:

    rake db:migrate

You may also need to configure the following items:

  • Email when using email registration. Read more.

The path at which to mount the authentication routes. .

OmniAuth providers when using 3rd party oauth2 authentication. .

Cross Origin Request Settings when using cross-domain clients. .

Multiple model support may require additional steps. .

user model
define routes
include concerns
default settings
Read more
Read more
Read more
Read more
Read more
Read more
Read more
Read more