Add necessary spree api routes related to api keys for users and bring respective implementations from spree_api

This commit is contained in:
luisramos0
2019-07-19 18:03:25 +01:00
parent a267848394
commit 5182286218
2 changed files with 17 additions and 0 deletions

View File

@@ -136,6 +136,16 @@ module Spree
has_spree_role?('admin')
end
def generate_spree_api_key!
self.spree_api_key = SecureRandom.hex(24)
save!
end
def clear_spree_api_key!
self.spree_api_key = nil
save!
end
protected
def password_required?

View File

@@ -118,6 +118,13 @@ Spree::Core::Engine.routes.prepend do
end
end
end
resources :users do
member do
put :generate_api_key
put :clear_api_key
end
end
end
resources :orders do