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)


252
253
254
# File 'app/models/concerns/effective_devise_user.rb', line 252

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

#alternate_email=(value) ⇒ Object



244
245
246
# File 'app/models/concerns/effective_devise_user.rb', line 244

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)


257
258
259
# File 'app/models/concerns/effective_devise_user.rb', line 257

def block_from_invitation?
  false
end

#email_to_sObject

The user’s to_s when in an email



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

def email_to_s
  to_s
end

#inactive_messageObject



261
262
263
# File 'app/models/concerns/effective_devise_user.rb', line 261

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

#reinvite!Object



248
249
250
# File 'app/models/concerns/effective_devise_user.rb', line 248

def reinvite!
  invite!
end

#send_devise_notification(notification, *args) ⇒ Object

Send devise & devise_invitable emails via active job



271
272
273
274
275
276
277
278
279
280
# File 'app/models/concerns/effective_devise_user.rb', line 271

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 mode

Returns:

  • (Boolean)


266
267
268
# File 'app/models/concerns/effective_devise_user.rb', line 266

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