Module: UserHelpers

Included in:
BaseController, RTCPController
Defined in:
app/base/helpers/user.rb

Instance Method Summary collapse

Instance Method Details

#authorization_tokenObject



21
22
23
# File 'app/base/helpers/user.rb', line 21

def authorization_token
  params[:__authorization_token__] || cookies[:__authorization_token__]
end

#authorized_userObject



3
4
5
6
# File 'app/base/helpers/user.rb', line 3

def authorized_user
  return unless authorization_token
  # fetch user, e.g. User.find_by(authorization_token: authorization_token)
end

#authorized_user!Object



8
9
10
# File 'app/base/helpers/user.rb', line 8

def authorized_user!
  authorized_user || error(401)
end

#authorized_user_idObject



12
13
14
15
# File 'app/base/helpers/user.rb', line 12

def authorized_user_id
  return unless authorization_token
  # fetch user, e.g. User.where(authorization_token: authorization_token).pluck(:id)[0]
end

#authorized_user_id!Object



17
18
19
# File 'app/base/helpers/user.rb', line 17

def authorized_user_id!
  authorized_user_id || error(401)
end