Sha256: 957ccca46ba2a676a7cc07a13be245f44e6a80ef0bf44cd4f82be55cec99c076

Contents?: true

Size: 807 Bytes

Versions: 16

Compression:

Stored size: 807 Bytes

Contents

module Pageflow
  # Specialized User class containing invitation logic used by in the
  # users admin.
  class InvitedUser < User
    before_create :prepare_invitation
    after_create :send_invitation

    def send_invitation!
      prepare_invitation
      save(validate: false)
      send_invitation
    end

    private

    def prepare_invitation
      @token = generate_reset_password_token
    end

    def generate_reset_password_token
      raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)

      self.reset_password_token = enc
      self.reset_password_sent_at = Time.now.utc

      raw
    end

    def password_required?
      false
    end

    def send_invitation
      UserMailer.invitation('user_id' => id, 'password_token' => @token).deliver
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pageflow-12.6.0 app/models/pageflow/invited_user.rb
pageflow-12.5.0 app/models/pageflow/invited_user.rb
pageflow-12.4.1 app/models/pageflow/invited_user.rb
pageflow-12.4.0 app/models/pageflow/invited_user.rb
pageflow-12.3.0 app/models/pageflow/invited_user.rb
pageflow-12.2.0 app/models/pageflow/invited_user.rb
pageflow-12.1.0 app/models/pageflow/invited_user.rb
pageflow-12.0.4 app/models/pageflow/invited_user.rb
pageflow-12.0.3 app/models/pageflow/invited_user.rb
pageflow-12.0.2 app/models/pageflow/invited_user.rb
pageflow-12.0.1 app/models/pageflow/invited_user.rb
pageflow-0.11.4 app/models/pageflow/invited_user.rb
pageflow-0.11.3 app/models/pageflow/invited_user.rb
pageflow-0.11.2 app/models/pageflow/invited_user.rb
pageflow-0.11.1 app/models/pageflow/invited_user.rb
pageflow-0.11.0 app/models/pageflow/invited_user.rb