Module: ApiUserAuth::AuthUserHelper::ClassMethods

Defined in:
app/models/concerns/api_user_auth/auth_user_helper.rb

Overview

Class methods

Instance Method Summary collapse

Instance Method Details

#create_by_params(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/concerns/api_user_auth/auth_user_helper.rb', line 8

def create_by_params(params)
  email_exception if params[:email].blank?
  password_exception if params[:password].blank?

  auth_user = AuthUser.find_or_initialize_by(email: params[:email])

  if auth_user.new_record?
    auth_user.is_new = true
    auth_user.update_password(params[:password])
  else
    user_exist_exception
  end
  auth_user
end