Class: Searls::Auth::CreatesUser
- Inherits:
-
Object
- Object
- Searls::Auth::CreatesUser
- Defined in:
- lib/searls/auth/creates_user.rb
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
Instance Method Details
#call(params) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/searls/auth/creates_user.rb', line 9 def call(params) user = Searls::Auth.config.user_finder_by_email.call(params[:email]) || Searls::Auth.config.user_initializer.call(params) if user.persisted? Result.new(nil, false, ["An account already exists for that email address. <a href=\"#{login_path(**forwardable_params(params))}\">Log in</a> instead?"]) elsif (errors = Searls::Auth.config.validate_registration.call(user, params, [])).any? Result.new(nil, false, errors) else if params[:password].present? Searls::Auth.config.password_setter.call(user, params[:password]) if params[:password_confirmation].present? && user.respond_to?(:password_confirmation=) user.password_confirmation = params[:password_confirmation] end end if user.save Result.new(user, true) else Result.new(user, false, (user)) end end end |