openstax_connect 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,9 +49,22 @@ module OpenStax::Connect
49
49
  if @request.ssl? && @cookies.signed[:secure_user_id] != "secure#{@session[:user_id]}"
50
50
  sign_out! # hijacked
51
51
  else
52
- @connect_current_user = @session[:user_id] ?
53
- User.where(id: @session[:user_id]).first :
54
- User.anonymous
52
+ # If there is a session user_id, load up that user, otherwise set the anonymous user.
53
+
54
+ if @session[:user_id]
55
+ @connect_current_user = User.where(id: @session[:user_id]).first
56
+
57
+ # It could happen (normally in development) that there is a session user_id that
58
+ # doesn't map to a User in the db. In such a case, sign_out! to reset the state
59
+ if @connect_current_user.nil?
60
+ sign_out!
61
+ return
62
+ end
63
+ else
64
+ @connect_current_user = User.anonymous
65
+ end
66
+
67
+ # bring the app user inline with the connect user
55
68
  @app_current_user = user_provider.connect_user_to_app_user(@connect_current_user)
56
69
  end
57
70
  end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Connect
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-11 00:00:00.000000000 Z
12
+ date: 2013-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -189,7 +189,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  segments:
191
191
  - 0
192
- hash: 1060826092135377802
192
+ hash: 1536200191300701933
193
193
  required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  none: false
195
195
  requirements:
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  segments:
200
200
  - 0
201
- hash: 1060826092135377802
201
+ hash: 1536200191300701933
202
202
  requirements: []
203
203
  rubyforge_project:
204
204
  rubygems_version: 1.8.25