[Ovirt-devel] [PATCH server] 'Log out' functionality.

Jason Guiditta jguiditt at redhat.com
Fri Feb 6 22:05:47 UTC 2009


This does not 100% work as desired because you cannot kill
the browser http auth credential from the server side.  The
patch instead takes care of the server session, and assumes
you have already kill your local auth using the web developer
toolbar in firefox (found under Misc -> Clear private data).

Signed-off-by: Jason Guiditta <jguiditt at redhat.com>
---
 src/app/controllers/login_controller.rb   |    8 +++++++-
 src/app/views/layouts/_header_redux.rhtml |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/app/controllers/login_controller.rb b/src/app/controllers/login_controller.rb
index 2d8ee67..2f65f2e 100644
--- a/src/app/controllers/login_controller.rb
+++ b/src/app/controllers/login_controller.rb
@@ -20,9 +20,10 @@
 # Filters added to this controller apply to all controllers in the application.
 # Likewise, all the methods added will be available for all controllers.
 
-class LoginController < ActionController::Base
+class LoginController < ApplicationController
 
   before_filter :is_logged_in, :except => :login
+
   def login
     session[:user] = (ENV["RAILS_ENV"] == "production") ?
     user_from_principal(request.env["HTTP_X_FORWARDED_USER"]) :
@@ -30,6 +31,11 @@ class LoginController < ActionController::Base
     redirect_to :controller => "dashboard"
   end
 
+  def logout
+    session[:user] = nil
+    is_logged_in
+  end
+
   def user_from_principal(principal)
     principal.split('@')[0]
   end
diff --git a/src/app/views/layouts/_header_redux.rhtml b/src/app/views/layouts/_header_redux.rhtml
index a12d567..146220c 100644
--- a/src/app/views/layouts/_header_redux.rhtml
+++ b/src/app/views/layouts/_header_redux.rhtml
@@ -6,6 +6,7 @@
     <input id="textfield_effect" name="terms" value="Search" onkeypress="" onfocus="if( this.value == this.defaultValue ) this.value='';" type="text">
     <input id="searchbox-button" src="<%= image_path "icon_search.png"%>" title="Search" type="image">  |
   </form>
+  <%= link_to 'Log out', { :controller => "login", :action => "logout"}%>
 </div>
 
 <div class="header_titlebar">Resource Pools</div>
-- 
1.5.6.6




More information about the ovirt-devel mailing list