Class: Spree::Api::V1::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v1/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#sign_inObject



16
17
18
19
20
21
22
23
# File 'app/controllers/spree/api/v1/users_controller.rb', line 16

def 
  @user = Spree::User.find_by_email(params[:user][:email])
  if !@user.present? || !@user.valid_password?(params[:user][:password])
    unauthorized
    return 
  end
  @user.generate_spree_api_key! if @user.spree_api_key.blank?
end

#sign_upObject



7
8
9
10
11
12
13
14
# File 'app/controllers/spree/api/v1/users_controller.rb', line 7

def 
  @user = Spree::User.new(params[:user])
  if !@user.save
    unauthorized 
    return 
  end
  @user.generate_spree_api_key!
end