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
  1. Usage

Mounting Routes

PreviousUsageNextController Integration

Last updated 7 years ago

The authentication routes must be mounted to your project. This gem includes a route helper for this purpose:

mount_devise_token_auth_for - similar to devise_for, this method is used to append the routes necessary for user authentication. This method accepts the following arguments:

Argument

Type

Default

Description

class_name

string

'User'

The name of the class to use for authentication. This class must include the .

options

object

{at: 'auth'}

The will be prefixed by the path specified in the at param of this object.

Example:

# config/routes.rb
mount_devise_token_auth_for 'User', at: 'auth'

Any model class can be used, but the class will need to include for authentication to work properly.

You can mount this engine to any route that you like. /auth is used by default to conform with the defaults of the module and the plugin.

DeviseTokenAuth::Concerns::User
ng-token-auth
jToker
model concern described here
routes to be used for authentication