Module: CommandTower::Signup::AuthorizationHelper

Defined in:
lib/command_tower/signup/authorization_helper.rb

Constant Summary collapse

SCHEME =
"Signup"
HEADER =
"Authorization"

Class Method Summary collapse

Class Method Details

.extract_token(request) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/command_tower/signup/authorization_helper.rb', line 11

def extract_token(request)
  raw = request.headers[HEADER].to_s.strip
  return { error: :missing } if raw.blank?

  match = raw.match(/\A#{SCHEME}\s+(.+)\z/i)
  return { error: :invalid_format } unless match

  token = match[1].to_s.strip
  return { error: :missing } if token.blank?

  { token: token }
end