class Motion::Authentication::DeviseSimpleTokenAuth
Public Class Methods
sign_in(sign_in_url, params, &block)
click to toggle source
# File lib/project/strategies/devise_simple_token_auth.rb, line 5 def sign_in(sign_in_url, params, &block) HTTP.post(sign_in_url, json: { user: params }) do |response| if response.success? store_auth_tokens(response.object) end block.call(response) end end
sign_out(&block)
click to toggle source
# File lib/project/strategies/devise_simple_token_auth.rb, line 38 def sign_out(&block) MotionKeychain.remove :auth_email MotionKeychain.remove :auth_token block.call end
sign_up(sign_up_url, params, &block)
click to toggle source
# File lib/project/strategies/devise_simple_token_auth.rb, line 14 def sign_up(sign_up_url, params, &block) HTTP.post(sign_up_url, json: { user: params }) do |response| if response.success? store_auth_tokens(response.object) end block.call(response) end end
signed_in?()
click to toggle source
# File lib/project/strategies/devise_simple_token_auth.rb, line 34 def signed_in? !! MotionKeychain.get(:auth_token) end
store_auth_tokens(data)
click to toggle source
# File lib/project/strategies/devise_simple_token_auth.rb, line 23 def store_auth_tokens(data) MotionKeychain.set :auth_email, data["email"] MotionKeychain.set :auth_token, data["token"] end