Class: CrazyTrain::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- CrazyTrain::ApplicationController
show all
- Defined in:
- app/controllers/crazy_train/application_controller.rb
Instance Method Summary
collapse
Instance Method Details
#jwt_payload ⇒ Object
41
42
43
44
45
|
# File 'app/controllers/crazy_train/application_controller.rb', line 41
def jwt_payload
CrazyTrain::JWT.decode(jwt_token, CrazyTrain.config.secret).first
rescue StandardError
nil
end
|
#jwt_token ⇒ Object
35
36
37
38
39
|
# File 'app/controllers/crazy_train/application_controller.rb', line 35
def jwt_token
request.['Authorization'].split.last
rescue StandardError
nil
end
|
#setup_role ⇒ Object
23
24
25
|
# File 'app/controllers/crazy_train/application_controller.rb', line 23
def setup_role
switch_role(@role)
end
|
#switch_role(role) ⇒ Object
31
32
33
|
# File 'app/controllers/crazy_train/application_controller.rb', line 31
def switch_role(role)
ActiveRecord::Base.connection.execute("SET ROLE #{role};")
end
|
#teardown_role ⇒ Object
27
28
29
|
# File 'app/controllers/crazy_train/application_controller.rb', line 27
def teardown_role
switch_role(@default_role)
end
|