Changeset 7540
- Timestamp:
- Dec 3, 2018, 9:11:18 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/Download.java
r7352 r7540 173 173 catch (ItemNotFoundException ex) 174 174 { 175 // Create new SessionControl and redirect to a different URL 176 // The next request will of course cause a NotLoggedInException 175 177 sc = Application.newSessionControl(Base.WEBCLIENT_ID, request.getRemoteAddr(), null); 176 178 ID = sc.getId(); 177 } 178 if (sc == null || !sc.isLoggedIn()) 179 response.sendRedirect(contextPath+servletPath+"/-"+ID+"-"+path.toString()); 180 return; 181 } 182 if (!sc.isLoggedIn()) 179 183 { 180 184 request.setAttribute("ID", ID); 181 request.setAttribute("redirect", contextPath+servletPath+"/-"+ID+"-"+path.toString());182 185 throw new NotLoggedInException(); 183 186 } -
trunk/src/core/net/sf/basedb/core/Application.java
r7532 r7540 1023 1023 throw new PermissionDeniedException("Invalid remoteId ("+remoteId+"; expected: "+sc.getRemoteId()+")"); 1024 1024 } 1025 if (checkLoggedIn && !sc.isLoggedIn()) 1026 { 1027 log.warn("getSessionControl: User not logged in. externalClientId: "+externalClientId+"; remoteId: "+remoteId); 1028 throw new NotLoggedInException(); 1029 } 1025 1030 if (externalClientId != null && !sc.isAllowedToUseClient(externalClientId)) 1026 1031 { 1027 1032 log.warn("getSessionControl: Invalid externalClientId: "+externalClientId+"; expected: "+sc.getExternalClientId()); 1028 1033 throw new PermissionDeniedException(Permission.USE, "Client[externalId="+externalClientId+"]"); 1029 }1030 if (checkLoggedIn && !sc.isLoggedIn())1031 {1032 log.warn("getSessionControl: User not logged in. externalClientId: "+externalClientId+"; remoteId: "+remoteId);1033 throw new NotLoggedInException();1034 1034 } 1035 1035 sc.updateLastAccess(); -
trunk/www/common/close_popup.js
r7420 r7540 66 66 else if (refreshOpener) 67 67 { 68 myOpener.location.reload(); 68 if (myOpener.App) 69 { 70 myOpener.App.reloadWindow(true); 71 } 72 else 73 { 74 myOpener.location.reload(); 75 } 69 76 } 70 77 App.closeWindow(); -
trunk/www/exception/not_logged_in.jsp
r7500 r7540 39 39 import="net.sf.basedb.core.Application" 40 40 import="net.sf.basedb.core.SessionControl" 41 import="net.sf.basedb.core.DbControl"42 41 import="net.sf.basedb.clients.web.Base" 43 42 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 43 isErrorPage="true" 51 44 %> 52 45 <%@ 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 46 <% 62 47 final SessionControl sc = Base.getSessionControl(pageContext, true); … … 64 49 final String root = request.getContextPath()+"/"; 65 50 final String redirect = Values.getString((String)request.getAttribute("redirect")); 66 final DbControl dc = sc.newDbControl();67 51 68 52 try 69 53 { 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 54 %> 93 55 <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> 56 <base:head scripts="exception.js" /> 98 57 <base:body data-resize-if-popup="1"> 99 58 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> 59 <table style="margin: auto; max-width: 600px; margin-top:5em; margin-bottom: 1em;"> 60 <tr> 61 <td> 62 <h1>Not logged in</h1> 63 <div class="messagecontainer error" style="margin-top: 1em; padding: 1em; font-size: 120%;"> 64 You have been automatically logged out due to inactivity or because the 65 server has been restarted. 66 You may log in again and continue your work but unsaved changes 67 may have been lost. 68 </div> 69 </td> 70 </tr> 71 </table> 72 73 <base:buttongroup subclass="dialogbuttons"> 74 <base:button id="close" title="Close"/> 75 <base:button id="gologin" image="login.png" title="Login again…" /> 76 </base:buttongroup> 77 215 78 </base:body> 216 79 </base:page> … … 218 81 } 219 82 finally 220 { 221 if (dc != null) dc.close(); 222 } 83 {} 223 84 %> -
trunk/www/include/scripts/exception.js
r7419 r7540 42 42 Buttons.addClickHandler('showMoreDetails', exception.showMoreDetails); 43 43 Buttons.addClickHandler('continuePluginWizard', exception.continuePluginWizard); 44 Buttons.addClickHandler('gologin', exception.goLogin); 44 45 } 45 46 … … 106 107 } 107 108 109 exception.goLogin = function() 110 { 111 var url = App.getRoot()+'main.jsp?ID='+App.getSessionId(); 112 url += '&again=1' 113 Dialogs.openPopup(url, 'Login', 750, 450); 114 } 115 108 116 exception.showMoreDetails = function(event) 109 117 { -
trunk/www/include/scripts/main-2.js
r7494 r7540 170 170 Reload the current window. 171 171 */ 172 app.reloadWindow = function() 173 { 172 app.reloadWindow = function(wait) 173 { 174 if (wait) 175 { 176 setTimeout(App.reloadWindow, 250); 177 return; 178 } 174 179 window.location.reload(); 175 180 } -
trunk/www/login.js
r7538 r7540 26 26 var Login = function() 27 27 { 28 var pLoginForm = 'login';29 28 var pUseLastLogin = 1; 30 29 … … 45 44 } 46 45 } 47 48 Doc.show('the-login-form');49 46 50 47 // Information links … … 74 71 } 75 72 73 Doc.show('the-login-form', 'table'); 76 74 login.initForm(); 77 75 … … 81 79 setTimeout(login.reloadFootnote, 500); 82 80 } 83 84 if (window.Exception) Exception.fixWindow();85 81 } 86 82 … … 93 89 login.switchLoginForm = function(loginForm) 94 90 { 91 var frm = document.forms['login']; 95 92 var url = location.pathname+'?ID='+App.getSessionId(); 96 93 url += '&loginForm='+encodeURIComponent(loginForm); 94 if (frm.again) url += '&again='+encodeURIComponent(frm.again.value); 97 95 location.replace(url); 98 96 } … … 110 108 login.initForm = function() 111 109 { 112 var frm = document.forms[ pLoginForm];110 var frm = document.forms['login']; 113 111 if (!frm.login) return; 114 112 pUseLastLogin = Data.int(frm.login, 'use-last-login', 1); … … 119 117 { 120 118 frm.login.value = lastLogin; 121 Doc.show('timeout');122 119 } 123 120 } … … 206 203 login.setFocus = function() 207 204 { 208 var frm = document.forms[ pLoginForm];205 var frm = document.forms['login']; 209 206 var fieldToFocus = null; 210 207 if (!frm.login.value) … … 229 226 login.enableLogin = function() 230 227 { 231 var frm = document.forms[ pLoginForm];228 var frm = document.forms['login']; 232 229 frm.login.disabled = false; 233 230 frm.password.disabled = false; … … 243 240 login.doLogin = function(event) 244 241 { 245 var frm = document.forms[ pLoginForm];242 var frm = document.forms['login']; 246 243 // Check if login has been disabled 247 244 if (frm.login && frm.login.disabled) return; -
trunk/www/login.jsp
r7530 r7540 53 53 String ID = sc.getId(); 54 54 String cmd = request.getParameter("cmd"); 55 String again = request.getParameter("again");55 boolean again = Values.getBoolean(request.getParameter("again")); 56 56 boolean useAutoStartPage = false; 57 57 String root = request.getContextPath()+"/"; … … 210 210 } 211 211 212 if ( "1".equals(again))212 if (again) 213 213 { 214 214 if (errorMessage != null) 215 215 { 216 throw new WebException("popup", errorTitle, errorMessage);216 response.sendRedirect(root+"main.jsp?ID="+ID+"&again=1&login="+HTML.urlEncode(login)+"&loginForm="+HTML.encodeTags(loginForm)+"&error="+HTML.urlEncode(errorMessage)); 217 217 } 218 218 else -
trunk/www/main.jsp
r7538 r7540 69 69 final String login = Values.getString(request.getParameter("login"), ""); 70 70 final String error = Values.getString(request.getParameter("error"), null); 71 final boolean again = Values.getBoolean(request.getParameter("again")); 71 72 final String requestedLoginForm = Values.getString(request.getParameter("loginForm"), null); 72 73 final String root = request.getContextPath()+"/"; … … 82 83 String broadcastMessage = (String)application.getAttribute("broadcast.message"); 83 84 boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login")); 85 84 86 ItemResultIterator<News> news = null; 85 87 JspContext jspContext = ExtensionsControl.createContext(dc, pageContext); … … 120 122 %> 121 123 <base:page type="default"> 122 <base:head styles="login.css" scripts=" exception.js,~login.js">124 <base:head styles="login.css" scripts="~login.js"> 123 125 <ext:scripts context="<%=jspContext%>" /> 124 126 <ext:stylesheets context="<%=jspContext%>" /> … … 127 129 <form name="login" action="login.jsp" method="post"> 128 130 <input type="hidden" name="ID" value="<%=ID%>"> 131 <input type="hidden" name="again" value="<%=again?1:0%>"> 129 132 <input type="hidden" name="useAutoStartPage" value="1"> 130 133 <input type="hidden" name="deviceToken" value=""> 131 134 132 <table style="margin: auto; width: 700px; display: none;" id="the-login-form">135 <table style="margin: auto; max-width: 700px; display: none;" id="the-login-form"> 133 136 <tr> 134 137 <td> … … 205 208 tabindex="2"> 206 209 </td> 207 <td <%=extraField != null?"rowspan=\"2\"" : "" %> style="vertical-align: bottom;"><base:button 208 id="btnLogin" 209 subclass="<%=denyLogin ? "disabled" : ""%>" 210 image="login.png" title="Login" 211 tooltip="<%=HTML.encodeTags(broadcastTitle)%>" tabindex="4" /></td> 210 <td <%=extraField != null?"rowspan=\"2\"" : "" %> style="vertical-align: bottom;"> 211 <base:buttongroup> 212 <base:button 213 id="btnLogin" 214 subclass="<%=denyLogin ? "disabled" : ""%>" 215 image="login.png" title="Login" 216 tooltip="<%=HTML.encodeTags(broadcastTitle)%>" tabindex="4" 217 /> 218 <base:button 219 id="close" title="Cancel" tabindex="5" 220 visible="<%=again %>" 221 /> 222 </base:buttongroup> 223 </td> 212 224 </tr> 213 225 <% … … 271 283 <% 272 284 } 285 if (!again) 286 { 287 String aboutServer = sc.getClientDefaultSetting("server.about"); 288 if (aboutServer != null) 289 { 290 %> 291 <h3 style="margin-top: 1em;">About this server</h3> 292 <p> 293 <%=aboutServer%> 294 </p> 295 <base:icon id="aboutServer" image="bullet.png">More about this server</base:icon> 296 <% 297 } 298 %> 299 <h3 style="margin-top: 1em;">News and announcements 300 <% 301 if (RssNewsFeed.isEnabled()) 302 { 303 %> 304 <a href="info/news.rss" 305 title="Subscribe to news from this BASE server" 306 ><base:icon image="rss.png" style="float: right;" /></a> 307 <% 308 } 309 %> 310 </h3> 311 <div id="news" class="news"> 312 <% 313 if (broadcastTitle != null) 314 { 315 %> 316 <div class="item note sticky"> 317 <div class="headline"> 318 <span class="date"><%=dateFormatter.format(new Date())%></span> 319 <%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %> 320 </div> 321 <div class="text"><%=HTML.niceFormat(broadcastMessage)%></div> 322 </div> 323 <% 324 } 325 326 ItemQuery<News> query = News.getQuery(); 327 query.order(Orders.desc(Hql.property("sticky"))); 328 query.order(Orders.desc(Hql.property("newsDate"))); 329 query.order(Orders.desc(Hql.property("id"))); 330 query.setCacheResult(true); 331 query.setReturnTotalCount(true); 332 news = query.iterate(dc); 333 int numListed = 0; 334 while (news.hasNext()) 335 { 336 News n = news.next(); 337 if (numListed >= 10 && !n.isSticky()) break; 338 %> 339 <div class="item <%=n.isSticky() ? "note sticky" : ""%>"> 340 <div class="headline"> 341 <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span> 342 <%=HTML.encodeTags(n.getName())%> 343 </div> 344 <div class="text"><%=HTML.niceFormat(n.getDescription())%></div> 345 </div> 346 <% 347 numListed++; 348 } 349 if (numListed < news.getTotalCount()) 350 { 351 %> 352 <base:icon image="bullet.png" /><a href="info/news.jsp" 353 title="Show older news..."><%=news.getTotalCount()-numListed%> more</a> 354 <% 355 } 356 %> 357 </div> 358 <% 359 } 273 360 %> 274 <%275 String aboutServer = sc.getClientDefaultSetting("server.about");276 if (aboutServer != null)277 {278 %>279 <h3 style="margin-top: 1em;">About this server</h3>280 <p>281 <%=aboutServer%>282 </p>283 <base:icon id="aboutServer" image="bullet.png">More about this server</base:icon>284 <%285 }286 %>287 288 <h3 style="margin-top: 1em;">News and announcements289 <%290 if (RssNewsFeed.isEnabled())291 {292 %>293 <a href="info/news.rss"294 title="Subscribe to news from this BASE server"295 ><base:icon image="rss.png" style="float: right;" /></a>296 <%297 }298 %>299 </h3>300 <div id="news" class="news">301 <%302 if (broadcastTitle != null)303 {304 %>305 <div class="item note sticky">306 <div class="headline">307 <span class="date"><%=dateFormatter.format(new Date())%></span>308 <%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %>309 </div>310 <div class="text"><%=HTML.niceFormat(broadcastMessage)%></div>311 </div>312 <%313 }314 315 ItemQuery<News> query = News.getQuery();316 query.order(Orders.desc(Hql.property("sticky")));317 query.order(Orders.desc(Hql.property("newsDate")));318 query.order(Orders.desc(Hql.property("id")));319 query.setCacheResult(true);320 query.setReturnTotalCount(true);321 news = query.iterate(dc);322 int numListed = 0;323 while (news.hasNext())324 {325 News n = news.next();326 if (numListed >= 10 && !n.isSticky()) break;327 %>328 <div class="item <%=n.isSticky() ? "note sticky" : ""%>">329 <div class="headline">330 <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>331 <%=HTML.encodeTags(n.getName())%>332 </div>333 <div class="text"><%=HTML.niceFormat(n.getDescription())%></div>334 </div>335 <%336 numListed++;337 }338 if (numListed < news.getTotalCount())339 {340 %>341 <base:icon image="bullet.png" /><a href="info/news.jsp"342 title="Show older news..."><%=news.getTotalCount()-numListed%> more</a>343 <%344 }345 %>346 </div>347 361 </td> 348 362 </tr>
Note: See TracChangeset
for help on using the changeset viewer.