venice-main-classic/scripts/logout.js
Eric J. Bowersox ffc862426a added global UI properties, cookie-reading APIs to CookieControl, moved
HttpVeniceUISession initialization into a script file (session_init.js)
2002-05-12 08:53:28 +00:00

43 lines
1.8 KiB
JavaScript

// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2001-2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(Packages.com.silverwrist.venice.core);
importPackage(Packages.com.silverwrist.venice.except);
importPackage(Packages.com.silverwrist.venice.ui);
importPackage(Packages.com.silverwrist.venice.ui.helpers);
// Get the request object and the target URI.
rinput = bsf.lookupBean("request");
target = rinput.getParameter("tgt");
if (target==null)
target = "top.js.vs";
// If the user is not logged in, this script is a no-op - just bounce to the specified target.
user = rinput.user;
if (user.isLoggedIn())
{ // user is logged in - we want to log out
// TODO: only remove the login cookie if it was actually set!
cctl = vlib.queryCookieControl(rinput);
cctl.deleteCookie(rinput.getConfigProperty("login.cookie")); // remove the login cookie
sctl = vlib.querySessionControl(rinput);
sctl.endSession();
target = "top.js.vs"; // take 'em back to the top
} // end if
vlib.output(new Redirect(target,LinkTypes.SERVLET)); // do the redirect!