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)


241
242
243
# File 'app/models/concerns/effective_devise_user.rb', line 241

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

#alternate_email=(value) ⇒ Object



233
234
235
# File 'app/models/concerns/effective_devise_user.rb', line 233

def alternate_email=(value)
  super(value.to_s.strip.downcase.presence)
end

#block_from_invitation?Boolean

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

Returns:

  • (Boolean)


246
247
248
# File 'app/models/concerns/effective_devise_user.rb', line 246

def block_from_invitation?
  false
end

#email_to_sObject

The user’s to_s when in an email



229
230
231
# File 'app/models/concerns/effective_devise_user.rb', line 229

def email_to_s
  to_s
end

#inactive_messageObject



250
251
252
# File 'app/models/concerns/effective_devise_user.rb', line 250

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

#reinvite!Object



237
238
239
# File 'app/models/concerns/effective_devise_user.rb', line 237

def reinvite!
  invite!
end

#send_devise_notification(notification, *args) ⇒ Object

Send devise & devise_invitable emails via active job



260
261
262
263
264
265
266
267
268
269
# File 'app/models/concerns/effective_devise_user.rb', line 260

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)


255
256
257
# File 'app/models/concerns/effective_devise_user.rb', line 255

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