Changeset 6426
- Timestamp:
- Feb 27, 2014, 10:37:49 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/web-extensions.xml
r6401 r6426 146 146 </extension-point> 147 147 148 <extension-point 149 id="login-form"> 150 <action-class>net.sf.basedb.clients.web.extensions.login.LoginFormAction</action-class> 151 <name>Login form customization</name> 152 <description> 153 Extension point for customizing the login form. Makes it possible to change login 154 and/or password prompts, help texts, etc. Since there is only one login form, 155 only the first extension found for this extension point is used. 156 </description> 157 </extension-point> 158 148 159 <!-- 149 160 More extension points: -
trunk/www/exception/not_logged_in.jsp
r6309 r6426 39 39 import="net.sf.basedb.core.Application" 40 40 import="net.sf.basedb.core.SessionControl" 41 import="net.sf.basedb.core.DbControl" 41 42 import="net.sf.basedb.clients.web.Base" 42 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" 43 50 isErrorPage="true" 44 51 %> 45 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" 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 } 46 60 %> 47 61 <% … … 50 64 final String root = request.getContextPath()+"/"; 51 65 final String redirect = Values.getString((String)request.getAttribute("redirect")); 52 %> 53 <base:page type="default" menu="exception" title="Not logged in"> 54 <base:head scripts="exception.js,/login.js" styles="login.css" /> 55 <base:body data-resize-if-popup="1"> 56 57 <form action="<%=root%>login.jsp?again=1" method="post" name="login" target="Login"> 58 <input type="hidden" name="ID" value="<%=ID%>"> 59 <input type="hidden" name="redirect" value="<%=redirect%>"> 60 61 <table style="margin: auto; width: 600px; margin-top:5em; "> 62 <tr> 63 <td> 64 65 <table style="width: 100%;"> 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 %> 92 <base:page type="default" menu="exception" title="Not logged in"> 93 <base:head scripts="exception.js,/login.js" styles="login.css"> 94 <ext:scripts context="<%=jspContext%>" /> 95 <ext:stylesheets context="<%=jspContext%>" /> 96 </base:head> 97 <base:body data-resize-if-popup="1"> 98 99 <form action="<%=root%>login.jsp?again=1" method="post" name="login" target="Login"> 100 <input type="hidden" name="ID" value="<%=ID%>"> 101 <input type="hidden" name="redirect" value="<%=redirect%>"> 102 103 <table style="margin: auto; width: 640px; margin-top:5em; "> 66 104 <tr> 67 <td style="background-color: #000000; border-radius: 4px 0px 0px 4px;"><img src="<%=root%>images/baselogo.png" alt="BASE logo"></td> 68 <td> 69 <div id="loginform"> 70 <table> 71 <tr> 72 <th>Login</th> 73 <td><input class="text" type="text" name="login" 74 maxlength="100" style="width: 12em;" 75 tabindex="0"> 76 </td> 77 <td></td> 78 </tr> 79 <tr> 80 <th>Password</th> 81 <td> 82 <input class="text" type="password" name="password" id="password" maxlength="80" 83 style="width: 12em;" 105 <td> 106 <% 107 if (loginAction.getHelp() != null) 108 { 109 %> 110 <div class="messagecontainer help" style="font-style: italic;" id="login-help"> 111 <%=loginAction.getHelp() %> 112 </div> 113 <% 114 } 115 %> 116 <table style="width: 100%;"> 117 <tr> 118 <td style="background-color: #000000; border-radius: 4px 0px 0px 4px; width: 125px;"><img src="<%=root%>images/baselogo.png" alt="BASE logo"></td> 119 <td style="width: 515px;"> 120 <div id="loginform"> 121 <table style="width: 100%;"> 122 <tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row"> 123 <th><%=loginField.getPrompt() %></th> 124 <td colspan="2"><input class="text" name="login" id="login" 125 type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>" 126 value="" 127 <%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %> 128 <%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %> 129 <%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %> 130 <%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\" data-use-last-login=\"0\""%> 131 maxlength="100" 84 132 tabindex="0"> 85 </td> 86 <td> 87 <base:buttongroup> 88 <base:button id="btnLogin" image="login.png" title="Login" /> 89 <base:button id="close" title="Cancel" /> 90 </base:buttongroup> 91 </td> 92 </tr> 93 <tr> 94 <th></th> 95 <td colspan="2"> 96 <% 97 String forgotPassword = sc.getClientDefaultSetting("server.forgotten.password"); 98 String getAccount = sc.getClientDefaultSetting("server.get.account"); 99 if (forgotPassword != null) 100 { 133 </td> 134 </tr> 135 <tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row"> 136 <th><%=passwordField.getPrompt() %></th> 137 <td><input class="text" name="password" id="password" 138 type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>" 139 <%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %> 140 <%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %> 141 <%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %> 142 maxlength="80" 143 tabindex="0"> 144 </td> 145 <td> 146 <base:buttongroup> 147 <base:button id="btnLogin" image="login.png" title="Login" /> 148 <base:button id="close" title="Cancel" /> 149 </base:buttongroup> 150 </td> 151 </tr> 152 <tr> 153 <th></th> 154 <td colspan="2"> 155 <% 156 String forgotPassword = sc.getClientDefaultSetting("server.forgotten.password"); 157 String getAccount = sc.getClientDefaultSetting("server.get.account"); 158 if (forgotPassword != null) 159 { 160 %> 161 <base:icon id="forgotPassword" image="bullet.png" 162 tooltip="Click here if you have forgotten your password">Forgot your password?</base:icon> 163 <% 164 } 165 if (getAccount != null) 166 { 167 %> 168 <base:icon id="getAccount" image="bullet.png" 169 tooltip="Click here if you want to get an account on this server">Get an account!</base:icon> 170 <% 171 } 101 172 %> 102 < base:icon id="forgotPassword" image="bullet.png"103 tooltip="Click here if you have forgotten your password">Forgot your password?</base:icon>104 <%105 }106 if (getAccount != null)107 {108 %>109 <base:icon id="getAccount" image="bullet.png"110 tooltip="Click here if you want to get an account on this server">Get an account!</base:icon>111 <%112 }113 %>114 </td>115 </tr>116 </table>117 </div>118 173 </td> 174 </tr> 175 </table> 176 </div> 177 </td> 178 </tr> 179 </table> 180 181 <div class="messagecontainer error" id="timeout" style="display: none;"> 182 <b>Not logged in</b><br> 183 You have been automatically logged out due to inactivity or because the 184 server has been restarted. 185 You may log in again and continue your work but unsaved changes 186 may have been lost. 187 </div> 188 189 </td> 119 190 </tr> 120 191 </table> 121 122 <div class="messagecontainer error" id="timeout" style="display: none;"> 123 <b>Not logged in</b><br> 124 You have been automatically logged out due to inactivity or because the 125 server has been restarted. 126 You may log in again and continue your work but unsaved changes 127 may have been lost. 128 </div> 129 130 </td> 131 </tr> 132 </table> 133 134 </form> 135 </base:body> 136 </base:page> 192 193 </form> 194 </base:body> 195 </base:page> 196 <% 197 } 198 finally 199 { 200 if (dc != null) dc.close(); 201 } 202 %> -
trunk/www/include/menu.jsp
r6401 r6426 1155 1155 title="<%=menu.getString("switchuser.title") + "…"%>" 1156 1156 url="<%=root+"switch.jsp?ID="+ID%>" 1157 data-popup="Switch, 300, 200"1157 data-popup="Switch, 450, 300" 1158 1158 tooltip="<%=menu.getString("switchuser.tooltip")%>" 1159 1159 /> -
trunk/www/include/styles/login.css
r5977 r6426 66 66 } 67 67 68 #loginform > table > tbody > tr:first-child > th 68 #loginform > table > tbody > tr:first-child > th, #loginform > table > tbody > tr > th.subprompt 69 69 { 70 70 border-top: 0px; 71 } 72 73 #loginform input 74 { 75 width: 15em; 71 76 } 72 77 -
trunk/www/login.js
r6400 r6426 38 38 39 39 // Login buttons 40 Events.doOnEnter('login', login.setFocus); 40 41 Buttons.addClickHandler('btnLogin', login.doLogin); 41 42 Buttons.addClickHandler('btnLoginAnyway', login.enableLogin); -
trunk/www/main.jsp
r6405 r6426 40 40 import="net.sf.basedb.core.query.Orders" 41 41 import="net.sf.basedb.core.query.Hql" 42 import="net.sf.basedb.util.extensions.ExtensionsInvoker" 42 43 import="net.sf.basedb.clients.web.Base" 43 44 import="net.sf.basedb.clients.web.util.HTML" 44 45 import="net.sf.basedb.util.formatter.Formatter" 46 import="net.sf.basedb.clients.web.extensions.ExtensionsControl" 47 import="net.sf.basedb.clients.web.extensions.JspContext" 45 48 import="net.sf.basedb.clients.web.formatter.FormatterFactory" 46 49 import="net.sf.basedb.clients.web.servlet.RssNewsFeed" 50 import="net.sf.basedb.clients.web.extensions.login.LoginFormAction" 51 import="net.sf.basedb.clients.web.extensions.login.LoginFormBean" 52 import="net.sf.basedb.clients.web.extensions.login.FieldInfo" 47 53 import="net.sf.basedb.util.Values" 48 54 import="java.util.Date" 49 55 %> 50 56 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 57 <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> 58 <%! 59 // If value is null, return "", else <prefix>+<value>+<suffix> 60 String valueIfNotNull(String prefix, String value, String suffix) 61 { 62 return value == null ? "" : prefix+value+suffix; 63 } 64 %> 51 65 <% 52 66 final String login = Values.getString(request.getParameter("login"), ""); … … 58 72 final Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); 59 73 final DbControl dc = sc.newDbControl(); 60 String broadcastTitle = (String)application.getAttribute("broadcast.title"); 61 String broadcastMessage = (String)application.getAttribute("broadcast.message"); 62 boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login")); 63 ItemResultList<News> news = null; 74 64 75 try 65 76 { 77 String broadcastTitle = (String)application.getAttribute("broadcast.title"); 78 String broadcastMessage = (String)application.getAttribute("broadcast.message"); 79 boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login")); 80 ItemResultList<News> news = null; 81 JspContext jspContext = ExtensionsControl.createContext(dc, pageContext); 82 ExtensionsInvoker<LoginFormAction> invoker = (ExtensionsInvoker<LoginFormAction>)ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.login-form"); 83 84 LoginFormAction loginAction = null; 85 for (LoginFormAction action : invoker) 86 { 87 if (action != null) 88 { 89 loginAction = action; 90 break; 91 } 92 } 93 if (loginAction == null) 94 { 95 LoginFormBean bean = new LoginFormBean(); 96 bean.setRememberLastLogin(true); 97 bean.setLoginField(FieldInfo.DEFAULT_LOGIN); 98 bean.setPasswordField(FieldInfo.DEFAULT_PASSWORD); 99 loginAction = bean; 100 } 101 102 FieldInfo loginField = loginAction.getLoginField(); 103 FieldInfo passwordField = loginAction.getPasswordField(); 66 104 %> 67 105 <base:page type="default"> 68 <base:head styles="login.css" scripts="exception.js,~login.js" /> 69 106 <base:head styles="login.css" scripts="exception.js,~login.js"> 107 <ext:scripts context="<%=jspContext%>" /> 108 <ext:stylesheets context="<%=jspContext%>" /> 109 </base:head> 70 110 <base:body style="padding-top: 5em;"> 71 111 <form name="login" action="login.jsp" method="post"> … … 73 113 <input type="hidden" name="nextpage" value="<%=root%>my_base/user/index.jsp"> 74 114 75 <table style="margin: auto; width: 6 00px;">115 <table style="margin: auto; width: 640px;"> 76 116 <tr> 77 117 <td> 118 <% 119 if (loginAction.getHelp() != null) 120 { 121 %> 122 <div class="messagecontainer help" style="font-style: italic;" id="login-help"> 123 <%=loginAction.getHelp() %> 124 </div> 125 <% 126 } 127 if (error != null) 128 { 129 %> 130 <div class="messagecontainer error"><%=error%></div> 131 <% 132 } 133 %> 78 134 <table style="width: 100%;"> 79 135 <tr> 80 <td style="background-color: #000000; border-radius: 4px 0px 0px 4px; "><img src="images/baselogo.png" alt="BASE logo"></td>81 <td >136 <td style="background-color: #000000; border-radius: 4px 0px 0px 4px; width: 125px;"><img src="images/baselogo.png" alt="BASE logo"></td> 137 <td style="width: 515px;"> 82 138 <div id="loginform"> 83 <table> 84 <tr> 85 <th>Login</th> 86 <td><input class="text" type="text" name="login" value="<%=HTML.encodeTags(login)%>" 87 maxlength="100" style="width: 12em;" <%=denyLogin ? "disabled" : ""%> 139 <table style="width: 100%;"> 140 <tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row"> 141 <th><%=loginField.getPrompt() %></th> 142 <td colspan="2"><input class="text" name="login" id="login" 143 type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>" 144 value="<%=loginAction.rememberLastLogin() ? HTML.encodeTags(login) : ""%>" 145 <%=denyLogin ? "disabled" : ""%> 146 <%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %> 147 <%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %> 148 <%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %> 149 <%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\" data-use-last-login=\"0\""%> 150 maxlength="100" 88 151 tabindex="0"> 89 152 </td> 90 <td></td>91 153 </tr> 92 <tr> 93 <th>Password</th> 94 <td> 95 <input class="text" type="password" name="password" id="password" maxlength="80" 96 style="width: 12em;" <%=denyLogin ? "disabled" : ""%> 97 tabindex="0"> 154 <tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row"> 155 <th><%=passwordField.getPrompt() %></th> 156 <td><input class="text" name="password" id="password" 157 type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>" 158 <%=denyLogin ? "disabled" : ""%> 159 <%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %> 160 <%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %> 161 <%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %> 162 maxlength="80" 163 tabindex="0"> 98 164 </td> 99 165 <td><base:button … … 104 170 </tr> 105 171 <tr> 106 <th ></th>172 <th class="subprompt"></th> 107 173 <td colspan="2"> 108 174 <% … … 128 194 </table> 129 195 </div> 130 131 132 196 </td> 133 197 </tr> 134 198 </table> 135 136 137 <%138 if (error != null)139 {140 %>141 <div class="messagecontainer error"><%=error%></div>142 <%143 }144 %>145 199 <% 146 200 if (denyLogin) … … 157 211 } 158 212 %> 159 160 213 <% 161 214 String aboutServer = sc.getClientDefaultSetting("server.about"); -
trunk/www/switch.jsp
r6167 r6426 32 32 import="net.sf.basedb.core.query.Orders" 33 33 import="net.sf.basedb.core.query.Hql" 34 import="net.sf.basedb.util.extensions.ExtensionsInvoker" 34 35 import="net.sf.basedb.clients.web.Base" 35 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" 36 42 import="net.sf.basedb.util.Values" 37 43 %> 38 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 %> 39 53 <% 40 54 final String login = Values.getString(request.getParameter("login"), ""); … … 45 59 try 46 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(); 47 82 %> 48 83 <base:page type="popup" title="Switch user"> 49 <base:head styles="login.css" scripts="~login.js" /> 84 <base:head styles="login.css" scripts="~login.js"> 85 <ext:scripts context="<%=jspContext%>" /> 86 <ext:stylesheets context="<%=jspContext%>" /> 87 </base:head> 50 88 <base:body> 51 89 <h1>Switch user <base:help helpid="switchuser" /></h1> … … 55 93 <input type="hidden" name="redirect" value=""> 56 94 57 <div class="content"> 95 <div class="content filled"> 96 <div> 58 97 <table class="fullform input100 bottomborder "> 59 <tr> 60 <th>Login</th> 61 <td><input type="text" name="login" value="<%=HTML.encodeTags(login)%>" maxlength="100" data-use-last-login="0"></td> 98 <tr <%=valueIfNotNull("class=\"", loginField.getClazz(), "\"")%> id="login-row"> 99 <th><%=loginField.getPrompt() %></th> 100 <td><input class="text" name="login" id="login" 101 type="<%=loginField.hasHiddenCharacters() ? "password" : "text"%>" 102 value="<%=loginAction.rememberLastLogin() ? HTML.encodeTags(login) : ""%>" 103 <%=valueIfNotNull("style=\"", loginField.getStyle(), "\"") %> 104 <%=valueIfNotNull("title=\"", loginField.getTooltip(), "\"") %> 105 <%=valueIfNotNull("placeholder=\"", loginField.getPlaceHolder(), "\"") %> 106 <%=loginAction.rememberLastLogin() ? "" : "autocomplete=\"off\""%> 107 data-use-last-login="0" 108 maxlength="100" 109 tabindex="0"> 110 </td> 62 111 </tr> 63 <tr> 64 <th>Password</th> 65 <td><input type="password" name="password" id="password" maxlength="80"></td> 112 <tr <%=valueIfNotNull("class=\"", passwordField.getClazz(), "\"")%> id="password-row"> 113 <th><%=passwordField.getPrompt() %></th> 114 <td><input class="text" name="password" id="password" 115 type="<%=passwordField.hasHiddenCharacters() ? "password" : "text"%>" 116 <%=valueIfNotNull("style=\"", passwordField.getStyle(), "\"") %> 117 <%=valueIfNotNull("title=\"", passwordField.getTooltip(), "\"") %> 118 <%=valueIfNotNull("placeholder=\"", passwordField.getPlaceHolder(), "\"") %> 119 maxlength="80" 120 tabindex="0"> 121 </td> 66 122 </tr> 67 123 <tr> … … 69 125 <td><input type="checkbox" name="remainOnPage" id="remainOnPage" checked value="1"></td> 70 126 </tr> 71 <tr class="dynamic">72 <th></th>73 <td></td>74 </tr>75 127 </table> 128 </div> 129 130 <div class="padded"> 131 <% 132 if (loginAction.getHelp() != null) 133 { 134 %> 135 <div class="messagecontainer help" style="font-style: italic;" id="login-help"> 136 <%=loginAction.getHelp() %> 137 </div> 138 <% 139 } 140 %> 141 </div> 142 76 143 </div> 77 144 </form>
Note: See TracChangeset
for help on using the changeset viewer.