omniauth-applicaster 1.3.0 → 1.3.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: 8cdfcee895b255c8a6aab814044d79692d2a1b0f
4
- data.tar.gz: 5d43ff220df15f20799c267c6e7b004e33928b9e
3
+ metadata.gz: 2d72901376c9698e3c3e8c5c411c051e616c3a71
4
+ data.tar.gz: e6bb8bb5e953da8d08ce56e16059f637922b0ada
5
5
  SHA512:
6
- metadata.gz: 94660689cb5cbe63ae03646dd6fedcb3de2aac8a9aaf9560cb775e2f79a5b3c24a116d81dafefe6e19ae0e7edc38fd5b9d58cdd5cc84741084df3773097713b5
7
- data.tar.gz: 5ce0f144b60f822b1b4809acd5dc777c80d3e78db654f87431c59a0ba7ef2faa106d40f2801abbe928c72f4cf5cb32775cd56309f3fd8b85275b6b3e231ca3d9
6
+ metadata.gz: 7c3d8a9f3829ff1c87623e042db0987156b8e3c39cd6aaed7179d6c11214e527b3819c10c3e3d7777bfaef1dcb8a4474b24f680a013a1de55a8485167c79b421
7
+ data.tar.gz: e6b3850aa5f59dca554a2c973e3904d840e71abed41c6b478e2c574791bf8be64cc968dc40342454efb882f4b2d0cf05c9b21c2f9bc1adf73211b542a488150e
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+ rescue LoadError
10
+ # no rspec available
11
+ end
12
+
@@ -15,14 +15,21 @@ module Applicaster
15
15
  end
16
16
  end
17
17
 
18
+ def current_access_token
19
+ session[:omniauth_credentials][:token] if session[:omniauth_credentials]
20
+ end
21
+
18
22
  protected
19
23
 
24
+ def clear_omniauth_credentials
25
+ session.delete(:omniauth_credentials)
26
+ end
27
+
20
28
  def user_from_session
21
- return nil unless session[:omniauth_credentials]
29
+ return nil unless current_access_token
22
30
 
23
- token = session[:omniauth_credentials][:token]
24
- Applicaster::Accounts.user_from_token(token).tap do |user|
25
- session.delete(:omniauth_credentials) unless user
31
+ Applicaster::Accounts.user_from_token(current_access_token).tap do |user|
32
+ clear_omniauth_credentials unless user
26
33
  end
27
34
  end
28
35
  end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Applicaster
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -92,6 +92,24 @@ RSpec.describe Applicaster::AuthHelpers do
92
92
  end
93
93
  end
94
94
 
95
+ describe "#current_access_token" do
96
+ it "returns access token" do
97
+ expect(controller.current_access_token).to eq(
98
+ session[:omniauth_credentials][:token]
99
+ )
100
+ end
101
+
102
+ context "when session has no omniauth_credentials" do
103
+ it "returns nil" do
104
+ expect(controller.current_access_token).to be nil
105
+ end
106
+
107
+ def session
108
+ {}
109
+ end
110
+ end
111
+ end
112
+
95
113
  def session
96
114
  {
97
115
  omniauth_credentials: {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-applicaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neer Friedman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler