q_auth_ruby_client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aff09df7afe70c5c433f9bc78d269aba97b18f28
|
4
|
+
data.tar.gz: 06db746aac1cefdd1397a55c171c2b00e0955098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b23aac9ff778d2dcb299385943bd94b91c2860749c5808524b04ce8b1c9d30508253a9669b501d792d00ebf53df02e1c2cf23524ccab821b735045a1e37d6c3c
|
7
|
+
data.tar.gz: 561b38e3bdac8fbf8fd72ee0f9b25d93052088cd81a1c7f7733b9b083cc8faa857e68197026e7ffdb57a6948a2f5f75b5c6008a29a1f259de045641d782b4ce3
|
@@ -31,10 +31,12 @@ class QAuthRubyClient::SessionsController < ApplicationController
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def sign_out
|
34
|
+
auth_token = current_user.auth_token
|
34
35
|
set_flash_message("You have successfully signed out", :notice)
|
35
36
|
# Reseting the auth token for user when he logs out.
|
36
37
|
# @current_user.update_attribute :auth_token, SecureRandom.hex
|
37
38
|
session.delete(:id)
|
39
|
+
response = QAuthRubyClient::User.destroy_session(auth_token)
|
38
40
|
redirect_to default_redirect_url_after_sign_out
|
39
41
|
end
|
40
42
|
|
@@ -60,6 +60,7 @@ class QAuthRubyClient::User < ActiveRecord::Base
|
|
60
60
|
self.state = data["state"]
|
61
61
|
self.country = data["country"]
|
62
62
|
|
63
|
+
self.auth_token = data["auth_token"]
|
63
64
|
self.token_created_at = data["token_created_at"] || Time.now - 1.day
|
64
65
|
self.user_type = data["user_type"]
|
65
66
|
|
@@ -93,6 +94,18 @@ class QAuthRubyClient::User < ActiveRecord::Base
|
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
97
|
+
def self.destroy_session(auth_token)
|
98
|
+
qauth_url = QAuthRubyClient.configuration.q_auth_url + "/api/v1/sign_out"
|
99
|
+
request = Typhoeus::Request.new(
|
100
|
+
qauth_url,
|
101
|
+
method: :delete,
|
102
|
+
headers: {"Authorization" => "Token token=#{auth_token}"},
|
103
|
+
verbose: false
|
104
|
+
)
|
105
|
+
response = JSON.parse(request.run.body)
|
106
|
+
return response
|
107
|
+
end
|
108
|
+
|
96
109
|
def token_expired?
|
97
110
|
return self.token_created_at.nil? || (Time.now > self.token_created_at + QAuthRubyClient.configuration.session_time_out)
|
98
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: q_auth_ruby_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krishnaprasad Varma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|