module Croods::Resource::Authentication

Constants

ATTRIBUTES
OPTIONS

Public Instance Methods

add_model_authentication(*options) click to toggle source
# File lib/croods/resource/authentication.rb, line 31
def add_model_authentication(*options)
  extend_model do
    before_create do
      self.uid = email unless uid.present?
    end

    extend Devise::Models

    devise_options = options.empty? ? OPTIONS : options
    devise(*devise_options)

    include DeviseTokenAuth::Concerns::User
  end
end
use_for_authentication!(*options) click to toggle source
# File lib/croods/resource/authentication.rb, line 19
def use_for_authentication!(*options)
  add_model_authentication(*options)

  skip_attributes(*ATTRIBUTES)
  skip_attribute(Croods.tenant_attribute) if Croods.multi_tenancy?

  request do
    add_attribute :password, :string, null: false
    skip_attribute :admin
  end
end