Module: EffectiveDeviseUser

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/effective_devise_user.rb

Overview

EffectiveDeviseUsr

Mark your user model with devise_for then effective_devise_user

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#active_for_authentication?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'app/models/concerns/effective_devise_user.rb', line 138

def active_for_authentication?
  super && (respond_to?(:archived?) ? !archived? : true)
end

#inactive_messageObject



142
143
144
# File 'app/models/concerns/effective_devise_user.rb', line 142

def inactive_message
  (respond_to?(:archived?) && archived?) ? :archived : super
end

#reinvite!Object

EffectiveDeviseUser Instance Methods



134
135
136
# File 'app/models/concerns/effective_devise_user.rb', line 134

def reinvite!
  invite!
end

#send_devise_notification(notification, *args) ⇒ Object

Send devise & devise_invitable emails via active job



152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'app/models/concerns/effective_devise_user.rb', line 152

def send_devise_notification(notification, *args)
  raise('expected args Hash') unless args.respond_to?(:last) && args.last.kind_of?(Hash)



  if defined?(Tenant)
    tenant = Tenant.current || raise('expected a current tenant')
    args.last[:tenant] ||= tenant
  end

  wait = (5 if notification == :invitation_instructions && !Rails.env.test?)

  devise_mailer.send(notification, self, *args).deliver_later(wait: wait)
end

#valid_password?(password) ⇒ Boolean

Any password will work in development or mode

Returns:

  • (Boolean)


147
148
149
# File 'app/models/concerns/effective_devise_user.rb', line 147

def valid_password?(password)
  Rails.env.development? || Rails.env.staging? || super
end