source: branches/3.3-stable/www/logout.jsp @ 6505

Last change on this file since 6505 was 6505, checked in by Nicklas Nordborg, 8 years ago

Fixes #1827: Do not warn about not being logged in when trying to log out

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1<%-- $Id: logout.jsp 6505 2014-08-06 07:38:36Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  Logout from BASE.
24
25  @param noconfirm
26    If specified on the URL we display a confirmation dialogue
27    otherwise we just log out and forward to the /main.jsp page
28
29  @author Nicklas
30  @version 2.0
31--%>
32<%@ page pageEncoding="UTF-8" session="false"
33  import="net.sf.basedb.core.SessionControl"
34  import="net.sf.basedb.core.User"
35  import="net.sf.basedb.util.Values"
36  import="net.sf.basedb.clients.web.Base"
37  import="net.sf.basedb.clients.web.WebException"
38  import="net.sf.basedb.clients.web.util.HTML"
39%>
40<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
41<%
42final SessionControl sc = Base.getExistingSessionControl(pageContext, false);
43final String ID = sc.getId();
44final boolean noconfirm = Values.getBoolean(request.getParameter("noconfirm"), !sc.isLoggedIn());
45if (noconfirm)
46{
47  // Redirect to main login page
48  String redirect = "common/close_popup.jsp?ID="+ID+"&wait=0&redirect_opener=../main.jsp?ID="+ID;;
49  if (sc.isImpersonated())
50  {
51    SessionControl original = (SessionControl)sc.getSessionSetting("impersonate.originalSessionControl");
52    boolean revert = Values.getBoolean(request.getParameter("revert"));
53    if (revert)
54    {
55      redirect = "common/close_popup.jsp?ID="+original.getId()+"&wait=0&redirect_opener=../my_base/index.jsp?ID="+original.getId();
56    }
57    else
58    {
59      original.logout();
60    }
61  }
62  sc.logout();
63  response.sendRedirect(redirect);
64  return;
65}
66String title = sc.isImpersonated() ? "Logout impersonated?" : "Logout?";
67%>
68<base:page type="popup" title="<%=title%>">
69<base:head scripts="~logout.js" />
70<base:body data-read-only="1">
71  <h1><%=title%></h1>
72  <div class="content">
73  <table class="fullcc"><tr><td>
74    <form action="logout.jsp" method="post" name="logout">
75    <input type="hidden" name="ID" value="<%=ID%>">
76    <input type="hidden" name="noconfirm" value="1">
77      <div id="confirm">
78        <b>Are you sure you want to logout? </b>
79        <br>
80        All unsaved data will be lost!
81        <% 
82        if (sc.isImpersonated())
83        {
84          User originalUser = (User)sc.getSessionSetting("impersonate.originalUser");
85          if (originalUser != null)
86          {
87            %>
88            <p>
89            <input type="checkbox" name="revert" id="revert" value="1" checked><label for="revert">Revert to
90            <%=HTML.encodeTags(originalUser.getName())%></label>
91            <%
92          }
93        }
94        %>
95      </div>
96      <div id="logout" style="display: none;">
97        <b>Logging out...</b>
98      </div>
99    </form>
100  </td></tr></table>
101  </div>
102  <base:buttongroup subclass="dialogbuttons" id="dialogbuttons">
103    <base:button id="btnLogout" title="Yes" />
104    <base:button id="close" title="No" />
105  </base:buttongroup>
106</base:body>
107</base:page>
Note: See TracBrowser for help on using the repository browser.