1 package org.tigris.scarab.actions; 2 3 48 49 import org.apache.turbine.TemplateContext; 51 import org.apache.turbine.RunData; 52 53 import org.tigris.scarab.om.ScarabUser; 54 import org.tigris.scarab.screens.ModuleSwitchingLink; 55 import org.tigris.scarab.tools.ScarabRequestTool; 56 import org.tigris.scarab.tools.localization.L10NKeySet; 57 import org.tigris.scarab.util.AnonymousUserUtil; 58 import org.tigris.scarab.util.ScarabConstants; 59 import org.tigris.scarab.actions.base.ScarabTemplateAction; 60 61 68 public class Logout extends ScarabTemplateAction 69 { 70 74 public void doLogout(RunData data, TemplateContext context) 75 throws Exception 76 { 77 ScarabRequestTool scarabR = getScarabRequestTool(context); 78 boolean bWasLoggedIn = data.getUserFromSession() != null && !((ScarabUser)data.getUserFromSession()).isUserAnonymous(); 79 scarabR.setCurrentModule(null); 80 data.getParameters().remove(ScarabConstants.CURRENT_MODULE); 81 data.setACL(null); 82 AnonymousUserUtil.anonymousLogin(data); 84 context.put("modulelink", new ModuleSwitchingLink(data)); 85 86 if(data.getUser()!=null) 87 { 88 data.save(); 89 if (bWasLoggedIn) 90 { 91 scarabR.setConfirmMessage(L10NKeySet.YouHaveBeenLoggedOut); 92 } 93 } 94 setTarget(data, "Login.vm"); 95 } 96 97 100 public void doPerform(RunData data, TemplateContext context) 101 throws Exception 102 { 103 doLogout(data, context); 104 } 105 } 106 | Popular Tags |