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)


173
174
175
# File 'app/models/concerns/effective_devise_user.rb', line 173

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

#block_from_invitation?Boolean

Allow users to sign in even if they have a pending invitation

Returns:

  • (Boolean)


178
179
180
# File 'app/models/concerns/effective_devise_user.rb', line 178

def block_from_invitation?
  false
end

#inactive_messageObject



182
183
184
# File 'app/models/concerns/effective_devise_user.rb', line 182

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

#reinvite!Object

EffectiveDeviseUser Instance Methods



169
170
171
# File 'app/models/concerns/effective_devise_user.rb', line 169

def reinvite!
  invite!
end

#send_devise_notification(notification, *args) ⇒ Object

Send devise & devise_invitable emails via active job



192
193
194
195
196
197
198
199
200
201
# File 'app/models/concerns/effective_devise_user.rb', line 192

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

  devise_mailer.send(notification, self, *args).deliver_now
end

#valid_password?(password) ⇒ Boolean

Any password will work in development or mode

Returns:

  • (Boolean)


187
188
189
# File 'app/models/concerns/effective_devise_user.rb', line 187

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