Sha256: 3b0343c67b6938579a4c2ed5b7329eb1c519c2ebe91c063ea17e23dc078af5ab

Contents?: true

Size: 666 Bytes

Versions: 5

Compression:

Stored size: 666 Bytes

Contents

require "uri"

class NoPassword::EmailAuthentication < NoPassword::Model
  attr_accessor :email
  validates :email,
    presence: true,
    format: { with: URI::MailTo::EMAIL_REGEXP }

  def verification
    # We don't want the code in the verification, otherwise
    # the user will set it on the subsequent request, which
    # would undermine the whole thing.
    NoPassword::Verification.new(salt: salt, data: email) if valid?
  end

  def destroy!
    secret.destroy!
  end

  private
    delegate :code, :salt, to: :secret

    def secret
      @secret ||= create_secret
    end

    def create_secret
      NoPassword::Secret.create!(data: email)
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nopassword-0.1.5 app/models/nopassword/email_authentication.rb
nopassword-0.1.4 app/models/nopassword/email_authentication.rb
nopassword-0.1.3 app/models/nopassword/email_authentication.rb
nopassword-0.1.2 app/models/nopassword/email_authentication.rb
nopassword-0.1.0 app/models/nopassword/email_authentication.rb