Method: ICFS::Demo::Auth#call
- Defined in:
- lib/icfs/demo/auth.rb
#call(env) ⇒ Object
Handle the calls
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/icfs/demo/auth.rb', line 42 def call(env) # login if env['PATH_INFO'] == '/login' user = env['QUERY_STRING'] body = 'User set' # set the cookie rsp = Rack::Response.new( body, 200, {} ) rsp.( 'icfs-user', { value: user, expires: Time.now + 24*60*60 }) return rsp.finish end # pull the username from the cookie = Rack::Request.new(env). user = ['icfs-user'] if !user return [400, {'Content-Type' => 'text/plain'}, ['Login first']] end # set up for the call @api.user = user env['icfs'] = @api return @app.call(env) rescue ICFS::Error::NotFound, ICFS::Error::Value => err return [400, {'Content-Type' => 'text/plain'}, [err.]] end |