Sha256: 4a447c05fd06d9e3024267197d1ce6965a0fd84c4d296e36f260bac302288830

Contents?: true

Size: 882 Bytes

Versions: 6

Compression:

Stored size: 882 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # A form object used to finish 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
    attribute :raw_data, Hash

    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
      UserBaseEntity.nicknamize(nickname || name, organization: current_organization)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.29.0 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.29.0.rc4 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.29.0.rc3 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.29.0.rc2 app/forms/decidim/omniauth_registration_form.rb
decidim-core-0.29.0.rc1 app/forms/decidim/omniauth_registration_form.rb