Sha256: 2076529b66f45dfbb5c38f13d3161c28aa4c9a7e5d14042e0dc4f01e822ea260

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

require "uri"

module Composable
  module Pwdless
    module Form
      class Authentication < Composable::Form::Command
        attribute :email
        validates :email, presence: true
        validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }, if: :email?

        def save
          # 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.
          Form::Verification.new(salt: salt, data: email)
        end

        private

        delegate :code, :salt, to: :secret

        def secret
          @secret ||= Pwdless::Secret.create!(data: email)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
composable-pwdless-0.0.12 app/services/composable/pwdless/form/authentication.rb
composable-pwdless-0.0.11 app/services/composable/pwdless/form/authentication.rb
composable-pwdless-0.0.10 app/services/composable/pwdless/form/authentication.rb