Sha256: e75cbfc98f08477b5019d242a976ed68f3ea73fd0976a8e427604d819855f662
Contents?: true
Size: 980 Bytes
Versions: 3
Compression:
Stored size: 980 Bytes
Contents
# frozen_string_literal: true module Decidim # The form object that handles the data behind updating a user's # account in her profile page. class AccountForm < Form mimic :user attribute :name attribute :email attribute :password attribute :password_confirmation attribute :avatar attribute :remove_avatar validates :name, presence: true validates :email, presence: true validates :password, confirmation: true validates :password, length: { in: Decidim::User.password_length, allow_blank: true } validates :password_confirmation, presence: true, if: :password_present validate :unique_email private def password_present !password.blank? end def unique_email return true if Decidim::User.where( organization: context.current_organization, email: email ).where.not(id: context.current_user.id).empty? errors.add :email, :taken false end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
decidim-core-0.0.6 | app/forms/decidim/account_form.rb |
decidim-core-0.0.5 | app/forms/decidim/account_form.rb |
decidim-core-0.0.3 | app/forms/decidim/account_form.rb |