isaca-rails 0.4.0 → 0.4.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
  SHA256:
3
- metadata.gz: d06cecd0537c57b9972bccd8f147bd4e5dd5827aa8a139960c84dd6c9545bb29
4
- data.tar.gz: 2dacf9bbc7b3e89e343952aec7aa937549f93e49dc8c8aeeb9560716d9fcc7c8
3
+ metadata.gz: 2e44dfe8d028791c15af16dbff0c76fd7856c039549c38992fec7f3009f60949
4
+ data.tar.gz: 4c02af179978947338db02822a276e0bb7f399c6b58e9a489c6ab31d10e83585
5
5
  SHA512:
6
- metadata.gz: aa885ba20b5b7d46ecc6036fff7d3577e60b95dcd44eba908f87a85cdc9e421acf41895a4a862019cdd38327bdc3fedad76c004441d410dcbf58d23a72b0e5f6
7
- data.tar.gz: e1397c6576e41eae69fa3eabb4213d40a3174f409c4027eadef29b11dc8d6e837647fdb44054034560ba588c544b89dc4ad3b92bc27da6f913bce729bc6c2e9c
6
+ metadata.gz: 646dc489fcab3ae19756a482f231a9d87ccc7282589535f49db71a9787a688c45bcb1fe08574a49243afcc11da804e39bc243a0757e108d3dd5d3142baef0cb5
7
+ data.tar.gz: 1150b56df2379d68f500a1af8fba5dab5cfd09ffb4017ee6b8fd527b8635e1cf274991b1067a5fa2561c2251107bad3b8a4224d0ea287bca1678f1b14c850e28
@@ -15,29 +15,22 @@ module Isaca
15
15
  #
16
16
  # @return nil
17
17
  def authenticate_isaca_user
18
- begin
19
- if user_signed_in?
20
- if request.path != user_consent_path && redirect_for_consent?
21
- session[:after_sign_in_path] = request.fullpath if request.get? && request.format.html?
22
- flash.alert = t('isaca.rails.user_consent.consent_required')
23
- redirect_to user_consent_path
24
- end
25
- else
26
- session[:after_sign_in_path] = request.fullpath if request.get?
27
- flash.alert = t('isaca.rails.sessions.sign_in_required')
28
-
29
- respond_to do |format|
30
- format.html {redirect_to sign_in_path}
31
- format.json do
32
- render json: {error: t('isaca.rails.sessions.sign_in_required')}.to_json, status: :unauthorized
33
- end
18
+ if user_signed_in?
19
+ if request.path != user_consent_path && redirect_for_consent?
20
+ session[:after_sign_in_path] = request.fullpath if request.get? && request.format.html?
21
+ flash.alert = t('isaca.rails.user_consent.consent_required')
22
+ redirect_to user_consent_path
23
+ end
24
+ else
25
+ session[:after_sign_in_path] = request.fullpath if request.get?
26
+ flash.alert = t('isaca.rails.sessions.sign_in_required')
27
+
28
+ respond_to do |format|
29
+ format.html {redirect_to sign_in_path}
30
+ format.json do
31
+ render json: {error: t('isaca.rails.sessions.sign_in_required')}.to_json, status: :unauthorized
34
32
  end
35
33
  end
36
- rescue Isaca::ServiceError => e
37
- cookies.delete('Token', domain: :all) if token_cookie_exists?
38
- @current_isaca_user = nil
39
- reset_session
40
- redirect_to sign_in_path, alert: "ISACA Service Error: #{e.message}"
41
34
  end
42
35
  end
43
36
 
@@ -127,12 +120,18 @@ module Isaca
127
120
  # @raise [Isaca::ServiceError] An error can be raised by {Isaca::Request::GetUserDetailsByToken#get} or {Isaca::Request::GetUserByID#get}
128
121
  def set_current_isaca_user
129
122
  # Using the Token cookie we can fetch our users details from isaca
130
- if Isaca::Rails.configuration.cache_sso
131
- isaca_user = ::Rails.cache.fetch("isaca/request/get_user_details_by_token/#{cookies['Token']}", expires_in: 2.minutes) do
132
- Isaca::Request::GetUserDetailsByToken.get(cookies['Token'])
123
+ begin
124
+ if Isaca::Rails.configuration.cache_sso
125
+ isaca_user = ::Rails.cache.fetch("isaca/request/get_user_details_by_token/#{cookies['Token']}", expires_in: 2.minutes) do
126
+ Isaca::Request::GetUserDetailsByToken.get(cookies['Token'])
127
+ end
128
+ else
129
+ isaca_user = Isaca::Request::GetUserDetailsByToken.get(cookies['Token'])
133
130
  end
134
- else
135
- isaca_user = Isaca::Request::GetUserDetailsByToken.get(cookies['Token'])
131
+ rescue Isaca::ExpiredTokenError => e
132
+ cookies.delete('Token', domain: :all) if token_cookie_exists?
133
+ reset_session
134
+ return nil
136
135
  end
137
136
 
138
137
  # The GetUserDetailsByToken endpoint does not return everything we need, we need to supplement our attributes
@@ -1,5 +1,5 @@
1
1
  module Isaca
2
2
  module Rails
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isaca-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Orahood