Module: Cyclid::UI::Helpers

Defined in:
app/cyclid_ui/helpers.rb

Overview

Various helper methods for Sinatra controllers

Instance Method Summary collapse

Instance Method Details

#csrf_tag(rack_env) ⇒ Object

CSRF HTML forms tag



26
27
28
# File 'app/cyclid_ui/helpers.rb', line 26

def csrf_tag(rack_env)
  Rack::Csrf.csrf_tag(rack_env)
end

#csrf_token(rack_env) ⇒ Object

Raw CSRF token



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

def csrf_token(rack_env)
  Rack::Csrf.csrf_token(rack_env)
end

#halt_with_401Object

Standard unauthenticated 401 message



31
32
33
34
# File 'app/cyclid_ui/helpers.rb', line 31

def halt_with_401
  flash[:login_error] = 'Invalid username or password'
  halt 401, flash.now[:login_error]
end