module Devise::Models::TokenAuthenticatable

def after_token_authentication

Hook called after token authentication.
def after_token_authentication
end

def ensure_authentication_token

Generate authentication token unless already exists.
def ensure_authentication_token
  reset_authentication_token if authentication_token.blank?
end

def ensure_authentication_token!

Generate authentication token unless already exists and save the record.
def ensure_authentication_token!
  reset_authentication_token! if authentication_token.blank?
end

def reset_authentication_token

Generate new authentication token (a.k.a. "single access token").
def reset_authentication_token
  self.authentication_token = self.class.authentication_token
end

def reset_authentication_token!

Generate new authentication token and save the record.
def reset_authentication_token!
  reset_authentication_token
  save(:validate => false)
end