biola_wcms_components 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ba9022051ffd2b2d4a5fef70903a54c04e4b57d
4
- data.tar.gz: 899c30df1835430be80716234a4a09a791799c98
3
+ metadata.gz: 21c30dd6c4f6db3bc50b76f3e6053bd5ea646aee
4
+ data.tar.gz: ad1c68725ca7097d71eaa323d1e29a6fae56b247
5
5
  SHA512:
6
- metadata.gz: 7d4892d0930864110ebf89c800adee222ed2dbd761f2fc6a68d95ae46d4ae6cfcff0bc69dbe244bff6859b058e7ed9f9df11f105f1c8575a22aa11c44c48cdfc
7
- data.tar.gz: 044236be86acddde92c7707611d2ffbb04c3b15d0bdbbe76157ca1833015ffefae6288e89dcf1f7f959b5610cbec5ed4631b78e246a2571e2798637faa916e0c
6
+ metadata.gz: 2598f4e0b5d374a740e476f77beaac3a3a84de77c0e7e824e029be15faf1758918a651efa96fb3c2dbd4b0d12710aa11aad9ecf4505690f1d67d8d831e5a7f3b
7
+ data.tar.gz: 28c07809f5e03bcc388fbd220aa66f868d5ba665e0acfe2abfbd10c37b1e7403d5183a8e8158bc0cd441ae04cc6535ff6dc933435c7f7af6366d6d7e5cb2924b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### Master (unreleased)
4
4
 
5
+ ### 0.22.0
6
+
7
+ * Adding support for user impersonation. This replaces the need for pretender.
8
+
5
9
  ### 0.21.0
6
10
 
7
11
  * Setting default ruby version to 2.1.6
@@ -9,13 +9,37 @@ class WcmsApplicationController < ActionController::Base
9
9
 
10
10
  layout -> { (@layout || :application).to_s }
11
11
 
12
- helper_method :current_user
13
- def current_user
12
+ def true_user
14
13
  authentication.user
15
14
  end
15
+ helper_method :true_user
16
+
17
+ def current_user
18
+ unless @current_user
19
+ # clear impersonation_id if true_user is not logged in
20
+ if session[:impersonation_id] && !true_user
21
+ session[:impersonation_id] = nil
22
+ end
23
+
24
+ # Fetch impersonated user from their ID, otherwise return true_user
25
+ @current_user = (session[:impersonation_id] && User.where(id: session[:impersonation_id]).first) || true_user
26
+ end
27
+ @current_user
28
+ end
29
+ helper_method :current_user
16
30
 
17
31
  protected
18
32
 
33
+ def impersonate_user(user)
34
+ @current_user = user
35
+ session[:impersonation_id] = user.id.to_s
36
+ end
37
+
38
+ def stop_impersonating_user
39
+ @impersonated_var = true_user
40
+ session[:impersonation_id] = nil
41
+ end
42
+
19
43
  def authenticate!
20
44
  authentication.perform or render_error_page(401)
21
45
  end
@@ -1,3 +1,3 @@
1
1
  module BiolaWcmsComponents
2
- VERSION = "0.21.0"
2
+ VERSION = "0.22.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biola_wcms_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Hall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2016-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ace-rails-ap