From 0415a8a298af5c34002dc9ffbe6bddcd6f8aaa96 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 17 Nov 2014 11:39:35 +0100 Subject: [PATCH] First version of showing uploaded logo. Need to be improved. --- .../javascripts/app/views/login.jst.eco | 2 +- app/controllers/sessions_controller.rb | 42 +++++++++++++++++++ config/routes/auth.rb | 1 + 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/views/login.jst.eco b/app/assets/javascripts/app/views/login.jst.eco index e5a98cdac..11217afd7 100644 --- a/app/assets/javascripts/app/views/login.jst.eco +++ b/app/assets/javascripts/app/views/login.jst.eco @@ -2,7 +2,7 @@

<%- @T( 'Login with %s', @C( 'fqdn' ) ) %>

- +
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 9b9e691dc..9fef0f8fc 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -278,4 +278,46 @@ class SessionsController < ApplicationController SessionHelper::destroy( params[:id] ) render :json => {} end + +=begin + +Resource: +GET /api/v1/sessions/logo + +Response: + + +Test: +curl http://localhost/api/v1/sessions/logo + +=end + + def logo + + # cache image + #response.headers['Expires'] = 1.year.from_now.httpdate + #response.headers["Cache-Control"] = "cache, store, max-age=31536000, must-revalidate" + #response.headers["Pragma"] = "cache" + + # find logo + list = Store.list( :object => 'System::Logo', :o_id => 2 ) + if list && list[0] + file = Store.find( list[0] ) + send_data( + file.content, + :filename => file.filename, + :type => file.preferences['Content-Type'], + :disposition => 'inline' + ) + return + end + + # serve default image + send_data( + '', + :filename => '', + :type => 'image/gif', + :disposition => 'inline' + ) + end end diff --git a/config/routes/auth.rb b/config/routes/auth.rb index 31b6717fd..a89ca2cf1 100644 --- a/config/routes/auth.rb +++ b/config/routes/auth.rb @@ -15,6 +15,7 @@ Zammad::Application.routes.draw do match api_path + '/sessions/switch/:id', :to => 'sessions#switch_to_user', :via => :get match api_path + '/sessions/switch_back', :to => 'sessions#switch_back_to_user', :via => :get match api_path + '/sessions', :to => 'sessions#list', :via => :get + match api_path + '/sessions/logo', :to => 'sessions#logo', :via => :get match api_path + '/sessions/:id', :to => 'sessions#delete', :via => :delete end \ No newline at end of file