1 | <%-- $Id: not_logged_in.jsp 7500 2018-08-08 10:57:12Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
---|
5 | Copyright (C) 2007 Nicklas Nordborg |
---|
6 | |
---|
7 | This file is part of BASE - BioArray Software Environment. |
---|
8 | Available at http://base.thep.lu.se/ |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 3 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | This page is used to catch NotLoggedInExceptions which are |
---|
25 | directed here via the exception.jsp page. NotLoggedInExceptions |
---|
26 | happen when a user tries to access a protected page without beeing |
---|
27 | logged in. Typically the exception is thrown from the method that |
---|
28 | retrieves the BaseControl object: |
---|
29 | |
---|
30 | BASE.getExistingBaseControl(pageContext); |
---|
31 | |
---|
32 | This page will display a new login form allowing the user |
---|
33 | to login again and continue with what he/she was doing. |
---|
34 | |
---|
35 | @author Nicklas |
---|
36 | @version 2.0 |
---|
37 | --%> |
---|
38 | <%@ page pageEncoding="UTF-8" session="false" |
---|
39 | import="net.sf.basedb.core.Application" |
---|
40 | import="net.sf.basedb.core.SessionControl" |
---|
41 | import="net.sf.basedb.core.DbControl" |
---|
42 | import="net.sf.basedb.clients.web.Base" |
---|
43 | import="net.sf.basedb.util.Values" |
---|
44 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
45 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
46 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
47 | import="net.sf.basedb.clients.web.extensions.login.LoginFormAction" |
---|
48 | import="net.sf.basedb.clients.web.extensions.login.LoginFormBean" |
---|
49 | import="net.sf.basedb.clients.web.extensions.login.FieldInfo" |
---|
50 | isErrorPage="true" |
---|
51 | %> |
---|
52 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
53 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
54 | <%! |
---|
55 | // If value is null, return "", else <prefix>+<value>+<suffix> |
---|
56 | String valueIfNotNull(String prefix, String value, String suffix) |
---|
57 | { |
---|
58 | return value == null ? "" : prefix+value+suffix; |
---|
59 | } |
---|
60 | %> |
---|
61 | <% |
---|
62 | final SessionControl sc = Base.getSessionControl(pageContext, true); |
---|
63 | final String ID = sc.getId(); |
---|
64 | final String root = request.getContextPath()+"/"; |
---|
65 | final String redirect = Values.getString((String)request.getAttribute("redirect")); |
---|
66 | final DbControl dc = sc.newDbControl(); |
---|
67 | |
---|
68 | try |
---|
69 | { |
---|
70 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext); |
---|
71 | ExtensionsInvoker<LoginFormAction> invoker = (ExtensionsInvoker<LoginFormAction>)ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.login-form"); |
---|
72 | LoginFormAction loginAction = null; |
---|
73 | for (LoginFormAction action : invoker) |
---|
74 | { |
---|
75 | if (action != null) |
---|
76 | { |
---|
77 | loginAction = action; |
---|
78 | break; |
---|
79 | } |
---|
80 | } |
---|
81 | if (loginAction == null) |
---|
82 | { |
---|
83 | LoginFormBean bean = new LoginFormBean(); |
---|
84 | bean.setRememberLastLogin(true); |
---|
85 | bean.setLoginField(FieldInfo.DEFAULT_LOGIN); |
---|
86 | bean.setPasswordField(FieldInfo.DEFAULT_PASSWORD); |
---|
87 | loginAction = bean; |
---|
88 | } |
---|
89 | FieldInfo loginField = loginAction.getLoginField(); |
---|
90 | FieldInfo passwordField = loginAction.getPasswordField(); |
---|
91 | FieldInfo extraField = loginAction.getExtraField(); |
---|
92 | %> |
---|
93 | <base:page type="default" menu="exception" title="Not logged in"> |
---|
94 | <base:head scripts="exception.js,/login.js" styles="login.css"> |
---|
95 | <ext:scripts context="<%=jspContext%>" /> |
---|
96 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
97 | </base:head> |
---|
98 | <base:body data-resize-if-popup="1"> |
---|
99 | |
---|
100 | <form action="<%=root%>login.jsp?again=1" method="post" name="login" target="Login"> |
---|
101 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
102 | <input type="hidden" name="redirect" value="<%=redirect%>"> |
---|
103 | <input type="hidden" name="useAutoStartPage" value="0"> |
---|
104 | <input type="hidden" name="deviceToken" value=""> |
---|
105 | |
---|
106 | <table style="margin: auto; width: 700px; margin-top:5em; "> |
---|
107 | <tr> |
---|
108 | <td> |
---|
109 | <% |
---|
110 | if (loginAction.getHelp() != null) |
---|
111 | { |
---|
112 | %> |
---|
113 | <div class="messagecontainer help" style="font-style: italic;" id="login-help"> |
---|
114 | <%=loginAction.getHelp() %> |
---|
115 | </div> |
---|
116 | <% |
---|
117 | } |
---|
118 | %> |
---|
119 | <table style="width: 100%; margin-top: 1em; border-collapse: separate;"> |
---|
120 | <tr> |
---|
121 | <td class="base-logo"><img src="<%=root%>images/baselogo.png" alt="BASE logo"></td> |
---|
122 | <td style="width: 515px;"> |
---|
123 | <div id="loginform"> |
---|
124 | <table style="width: 100%;"> |
---|
125 | <tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row"> |
---|
126 | <th class="bg-filled-100"><%=loginField.getPrompt() %></th> |
---|
127 | <td colspan="2"><input class="text" name="login" id="login" |
---|
128 | type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>" |
---|
129 | value="" |
---|
130 | <%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %> |
---|
131 | <%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %> |
---|
132 | <%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %> |
---|
133 | <%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\" data-use-last-login=\"0\""%> |
---|
134 | maxlength="100" |
---|
135 | tabindex="1"> |
---|
136 | </td> |
---|
137 | </tr> |
---|
138 | <tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row"> |
---|
139 | <th class="bg-filled-100"><%=passwordField.getPrompt() %></th> |
---|
140 | <td><input class="text" name="password" id="password" |
---|
141 | type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>" |
---|
142 | <%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %> |
---|
143 | <%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %> |
---|
144 | <%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %> |
---|
145 | maxlength="80" |
---|
146 | tabindex="2"> |
---|
147 | </td> |
---|
148 | <td <%=extraField != null?"rowspan=\"2\"" : "" %> style="vertical-align: bottom;"> |
---|
149 | <base:buttongroup> |
---|
150 | <base:button id="btnLogin" image="login.png" title="Login" tabindex="4"/> |
---|
151 | <base:button id="close" title="Cancel" tabindex="5" /> |
---|
152 | </base:buttongroup> |
---|
153 | </td> |
---|
154 | </tr> |
---|
155 | <% |
---|
156 | if (extraField != null) |
---|
157 | { |
---|
158 | %> |
---|
159 | <tr <%=valueIfNotNull("class=\"", extraField.getClazz(), "\"")%> id="extra-row"> |
---|
160 | <th class="bg-filled-100"><%=extraField.getPrompt() %></th> |
---|
161 | <td><input class="text" name="extraField" id="extraField" |
---|
162 | type="<%=extraField.hasHiddenCharacters() ? "password" : "text"%>" |
---|
163 | <%=valueIfNotNull("style=\"", extraField.getStyle(), "\"") %> |
---|
164 | <%=valueIfNotNull("title=\"", extraField.getTooltip(), "\"") %> |
---|
165 | <%=valueIfNotNull("placeholder=\"", extraField.getPlaceHolder(), "\"") %> |
---|
166 | maxlength="80" |
---|
167 | tabindex="3"> |
---|
168 | </td> |
---|
169 | </tr> |
---|
170 | <% |
---|
171 | } |
---|
172 | %> |
---|
173 | <tr> |
---|
174 | <th class="bg-filled-100"></th> |
---|
175 | <td colspan="2"> |
---|
176 | <% |
---|
177 | String forgotPassword = sc.getClientDefaultSetting("server.forgotten.password"); |
---|
178 | String getAccount = sc.getClientDefaultSetting("server.get.account"); |
---|
179 | if (forgotPassword != null) |
---|
180 | { |
---|
181 | %> |
---|
182 | <base:icon id="forgotPassword" image="bullet.png" |
---|
183 | tooltip="Click here if you have forgotten your password">Forgot your password?</base:icon> |
---|
184 | <% |
---|
185 | } |
---|
186 | if (getAccount != null) |
---|
187 | { |
---|
188 | %> |
---|
189 | <base:icon id="getAccount" image="bullet.png" |
---|
190 | tooltip="Click here if you want to get an account on this server">Get an account!</base:icon> |
---|
191 | <% |
---|
192 | } |
---|
193 | %> |
---|
194 | </td> |
---|
195 | </tr> |
---|
196 | </table> |
---|
197 | </div> |
---|
198 | </td> |
---|
199 | </tr> |
---|
200 | </table> |
---|
201 | |
---|
202 | <div class="messagecontainer error" id="timeout" style="display: none; margin-top: 1em;"> |
---|
203 | <b>Not logged in</b><br> |
---|
204 | You have been automatically logged out due to inactivity or because the |
---|
205 | server has been restarted. |
---|
206 | You may log in again and continue your work but unsaved changes |
---|
207 | may have been lost. |
---|
208 | </div> |
---|
209 | |
---|
210 | </td> |
---|
211 | </tr> |
---|
212 | </table> |
---|
213 | |
---|
214 | </form> |
---|
215 | </base:body> |
---|
216 | </base:page> |
---|
217 | <% |
---|
218 | } |
---|
219 | finally |
---|
220 | { |
---|
221 | if (dc != null) dc.close(); |
---|
222 | } |
---|
223 | %> |
---|