Module: Workarea::AdminGuestBrowsing
- Extended by:
- ActiveSupport::Concern
- Includes:
- Authentication
- Included in:
- Impersonation
- Defined in:
- app/controllers/workarea/admin_guest_browsing.rb
Instance Method Summary
collapse
#current_user, #logged_in?, #login, #logout, #redirect_back_or, #remember_location, #require_login, #require_logout, #require_password_changes, #return_to, #touch_auth_cookie
Instance Method Details
#admin_browse_as_guest ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/workarea/admin_guest_browsing.rb', line 10
def admin_browse_as_guest
session[:admin_id] = current_user.id
touch_admin_guest_browsing
logout
end
|
#admin_browsing_as_guest? ⇒ Boolean
16
17
18
|
# File 'app/controllers/workarea/admin_guest_browsing.rb', line 16
def admin_browsing_as_guest?
session[:admin_id].present? && cookies.signed[:guest_browsing]
end
|
#current_admin ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'app/controllers/workarea/admin_guest_browsing.rb', line 37
def current_admin
@current_admin ||=
if admin_browsing_as_guest?
User.find(session[:admin_id])
elsif current_user.try(:admin?)
current_user
end
end
|
#keep_auth_alive ⇒ Object
46
47
48
49
50
51
52
|
# File 'app/controllers/workarea/admin_guest_browsing.rb', line 46
def keep_auth_alive
if admin_browsing_as_guest?
touch_admin_guest_browsing
else
super
end
end
|
#stop_admin_guest_browsing ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/workarea/admin_guest_browsing.rb', line 20
def stop_admin_guest_browsing
cookies.signed[:user_id] = {
value: current_admin.id,
expires: Workarea.config.admin_session_timeout.from_now
}
session.delete(:admin_id)
cookies.delete(:guest_browsing)
end
|
#touch_admin_guest_browsing ⇒ Object
30
31
32
33
34
35
|
# File 'app/controllers/workarea/admin_guest_browsing.rb', line 30
def touch_admin_guest_browsing
cookies.signed[:guest_browsing] = {
value: true,
expires: Workarea.config.admin_session_timeout.from_now
}
end
|