Sha256: 6ab414156d94f42bbacac9891f7ef32129e9949d58370187ccb8ebcc759cab73

Contents?: true

Size: 807 Bytes

Versions: 7

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A form object used to fisnish signup from omniauth data
  class OmniauthRegistrationForm < Form
    mimic :user

    attribute :email, String
    attribute :name, String
    attribute :nickname, String
    attribute :provider, String
    attribute :uid, String
    attribute :tos_agreement, Boolean
    attribute :oauth_signature, String
    attribute :avatar_url, String

    validates :email, presence: true
    validates :name, presence: true
    validates :provider, presence: true
    validates :uid, presence: true

    def self.create_signature(provider, uid)
      Digest::MD5.hexdigest("#{provider}-#{uid}-#{Rails.application.secrets.secret_key_base}")
    end

    def normalized_nickname
      User.nicknamize(nickname || name)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.12.2 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.12.1 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.12.0 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.11.2 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.12.0.pre app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.11.1 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.11.0.pre1 app/forms/decidim/omniauth_registration_form.rb