1 | <%-- $Id: switch.jsp 7408 2017-10-06 09:37:18Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006, 2007 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 3 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
21 | |
---|
22 | @author Nicklas |
---|
23 | @version 2.0 |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.Application" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.News" |
---|
30 | import="net.sf.basedb.core.ItemQuery" |
---|
31 | import="net.sf.basedb.core.ItemResultList" |
---|
32 | import="net.sf.basedb.core.query.Orders" |
---|
33 | import="net.sf.basedb.core.query.Hql" |
---|
34 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
35 | import="net.sf.basedb.clients.web.Base" |
---|
36 | import="net.sf.basedb.clients.web.util.HTML" |
---|
37 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
38 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
39 | import="net.sf.basedb.clients.web.extensions.login.LoginFormAction" |
---|
40 | import="net.sf.basedb.clients.web.extensions.login.LoginFormBean" |
---|
41 | import="net.sf.basedb.clients.web.extensions.login.FieldInfo" |
---|
42 | import="net.sf.basedb.util.Values" |
---|
43 | %> |
---|
44 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
45 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
46 | <%! |
---|
47 | // If value is null, return "", else <prefix>+<value>+<suffix> |
---|
48 | String valueIfNotNull(String prefix, String value, String suffix) |
---|
49 | { |
---|
50 | return value == null ? "" : prefix+value+suffix; |
---|
51 | } |
---|
52 | %> |
---|
53 | <% |
---|
54 | final String login = Values.getString(request.getParameter("login"), ""); |
---|
55 | |
---|
56 | final SessionControl sc = Base.getSessionControl(pageContext, true); |
---|
57 | final String ID = sc.getId(); |
---|
58 | final DbControl dc = sc.newDbControl(); |
---|
59 | try |
---|
60 | { |
---|
61 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext); |
---|
62 | ExtensionsInvoker<LoginFormAction> invoker = (ExtensionsInvoker<LoginFormAction>)ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.login-form"); |
---|
63 | LoginFormAction loginAction = null; |
---|
64 | for (LoginFormAction action : invoker) |
---|
65 | { |
---|
66 | if (action != null) |
---|
67 | { |
---|
68 | loginAction = action; |
---|
69 | break; |
---|
70 | } |
---|
71 | } |
---|
72 | if (loginAction == null) |
---|
73 | { |
---|
74 | LoginFormBean bean = new LoginFormBean(); |
---|
75 | bean.setRememberLastLogin(true); |
---|
76 | bean.setLoginField(FieldInfo.DEFAULT_LOGIN); |
---|
77 | bean.setPasswordField(FieldInfo.DEFAULT_PASSWORD); |
---|
78 | loginAction = bean; |
---|
79 | } |
---|
80 | FieldInfo loginField = loginAction.getLoginField(); |
---|
81 | FieldInfo passwordField = loginAction.getPasswordField(); |
---|
82 | %> |
---|
83 | <base:page type="popup" title="Switch user"> |
---|
84 | <base:head styles="login.css" scripts="~login.js"> |
---|
85 | <ext:scripts context="<%=jspContext%>" /> |
---|
86 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
87 | </base:head> |
---|
88 | <base:body> |
---|
89 | <h1>Switch user <base:help helpid="switchuser" /></h1> |
---|
90 | <form name="login" action="login.jsp" method="post"> |
---|
91 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
92 | <input type="hidden" name="again" value="1"> |
---|
93 | <input type="hidden" name="redirect" value=""> |
---|
94 | <input type="hidden" name="useAutoStartPage" value="0"> |
---|
95 | <input type="hidden" name="deviceToken" value=""> |
---|
96 | |
---|
97 | <div class="content"> |
---|
98 | <table class="fullform input100 bottomborder "> |
---|
99 | <tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row"> |
---|
100 | <th><%=loginField.getPrompt() %></th> |
---|
101 | <td><input class="text" name="login" id="login" |
---|
102 | type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>" |
---|
103 | value="<%=loginAction.rememberLastLogin() ? HTML.encodeTags(login) : ""%>" |
---|
104 | <%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %> |
---|
105 | <%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %> |
---|
106 | <%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %> |
---|
107 | <%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\""%> |
---|
108 | data-use-last-login="0" |
---|
109 | maxlength="100" |
---|
110 | tabindex="0"> |
---|
111 | </td> |
---|
112 | </tr> |
---|
113 | <tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row"> |
---|
114 | <th><%=passwordField.getPrompt() %></th> |
---|
115 | <td><input class="text" name="password" id="password" |
---|
116 | type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>" |
---|
117 | <%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %> |
---|
118 | <%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %> |
---|
119 | <%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %> |
---|
120 | maxlength="80" |
---|
121 | tabindex="0"> |
---|
122 | </td> |
---|
123 | </tr> |
---|
124 | <tr> |
---|
125 | <th><label for="remainOnPage">Remain on this page</label></th> |
---|
126 | <td><input type="checkbox" name="remainOnPage" id="remainOnPage" checked value="1"></td> |
---|
127 | </tr> |
---|
128 | <% |
---|
129 | if (loginAction.getHelp() != null) |
---|
130 | { |
---|
131 | %> |
---|
132 | <tr class="dynamic bg-filled-50 topborder"> |
---|
133 | <td colspan="2"> |
---|
134 | <div class="padded"> |
---|
135 | <div class="messagecontainer help" style="font-style: italic;" id="login-help"> |
---|
136 | <%=loginAction.getHelp() %> |
---|
137 | </div> |
---|
138 | </div> |
---|
139 | </td> |
---|
140 | </tr> |
---|
141 | <% |
---|
142 | } |
---|
143 | else |
---|
144 | { |
---|
145 | %> |
---|
146 | <tr class="dynamic"> |
---|
147 | <th></th> |
---|
148 | <td></td> |
---|
149 | </tr> |
---|
150 | <% |
---|
151 | } |
---|
152 | %> |
---|
153 | </table> |
---|
154 | |
---|
155 | </div> |
---|
156 | </form> |
---|
157 | |
---|
158 | <base:buttongroup subclass="dialogbuttons"> |
---|
159 | <base:button id="btnLogin" image="login.png" title="Login" /> |
---|
160 | <base:button id="close" title="Cancel" /> |
---|
161 | </base:buttongroup> |
---|
162 | |
---|
163 | </base:body> |
---|
164 | </base:page> |
---|
165 | <% |
---|
166 | } |
---|
167 | finally |
---|
168 | { |
---|
169 | if (dc != null) dc.close(); |
---|
170 | } |
---|
171 | %> |
---|
172 | |
---|