Skip to content

Commit

Permalink
Working with spree v2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sliaquat committed Dec 6, 2014
1 parent 6b793ab commit e1f72a1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
28 changes: 28 additions & 0 deletions app/controllers/spree/api/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Spree
module Api

class UsersController < Spree::Api::BaseController
before_action :authenticate_user, :except => [:sign_up, :sign_in]

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

def sign_in
@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

end
end
end

28 changes: 0 additions & 28 deletions app/controllers/spree/api/v1/users_controller.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Spree::Core::Engine.routes.prepend do
namespace :api do
scope :module => :v1 do
namespace :users do
post :sign_up
post :sign_in
end
Spree::Core::Engine.add_routes do
namespace :api, defaults: { format: 'json' } do

namespace :users do
post :sign_up
post :sign_in
end

end
end

0 comments on commit e1f72a1

Please sign in to comment.