File: token_authenticatable.rb

package info (click to toggle)
ruby-devise-token-authenticatable 0.5.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 276 kB
  • sloc: ruby: 1,059; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,269 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require "devise/token_authenticatable/strategy"

module Devise
  module TokenAuthenticatable

    # Authentication token params key name of choice. E.g. /users/sign_in?some_key=...
    mattr_accessor :token_authentication_key
    @@token_authentication_key = :auth_token

    # Token expiration period. E.g. 1.day
    mattr_accessor :token_expires_in
    @@token_expires_in = nil

    # Defines if the authentication token is reset before the model is saved.
    mattr_accessor :should_reset_authentication_token
    @@should_reset_authentication_token = false

    # Defines if the authentication token is set - if not already - before the model is saved.
    mattr_accessor :should_ensure_authentication_token
    @@should_ensure_authentication_token = false

    # Enable the configuration of the TokenAuthenticatable
    # strategy with a block:
    #
    #   Devise::TokenAuthenticatable.setup do |config|
    #     config.token_authentication_key = :other_key
    #   end
    #
    def self.setup
      yield self
    end
  end
end

# Register TokenAuthenticatable module in Devise.
Devise::add_module  :token_authenticatable,
                    model: 'devise/token_authenticatable/model',
                    strategy: true,
                    no_input: true