Changeset 7529
- Timestamp:
- Nov 26, 2018, 8:30:41 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/login/LoginFormAction.java
r7500 r7529 22 22 package net.sf.basedb.clients.web.extensions.login; 23 23 24 import net.sf.basedb.core.authentication.LoginRequest; 24 25 import net.sf.basedb.util.extensions.Action; 25 26 … … 34 35 { 35 36 37 /** 38 Get the ID of this login form. It's main use it to 39 enable support for multiple installed authentication 40 managers. Clients that supports this should submit the 41 id of the login form via the "login-form" {@link LoginRequest} 42 attribute. Authentication managers should check this id 43 before determining if they should handle the login request 44 or not. 45 46 Since this is a new method in BASE 3.14 a default 47 implementation that returns null is provided for backwards 48 compatibility. If this method returns null, the id from 49 the extension is used instead. 50 @since 3.14 51 */ 52 public default String getId() 53 { 54 return null; 55 } 56 57 /** 58 Get a name that can be displayed for users in a selection list 59 or similar to switch between different login methods. 60 61 Since this is a new method in BASE 3.14 a default 62 implementation that returns null is provided for backwards 63 compatibility. If this method returns null, the name from 64 the extension is used instead. 65 @since 3.14 66 */ 67 public default String getDisplayName() 68 { 69 return null; 70 } 71 36 72 /** 37 73 Optional help text that is displayed on the login form to aid the -
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/login/LoginFormBean.java
r7500 r7529 31 31 implements LoginFormAction 32 32 { 33 private String id; 34 private String displayName; 33 35 34 36 private String help; … … 40 42 public LoginFormBean() 41 43 {} 44 45 @Override 46 public String getId() 47 { 48 return id; 49 } 50 public void setId(String id) 51 { 52 this.id = id; 53 } 54 55 @Override 56 public String getDisplayName() 57 { 58 return displayName; 59 } 60 public void setDisplayName(String displayName) 61 { 62 this.displayName = displayName; 63 } 64 42 65 43 66 @Override -
trunk/www/login.js
r7500 r7529 44 44 Buttons.addClickHandler('close', App.closeWindow); 45 45 46 Events.addEventHandler('loginForm', 'change', login.switchLoginForm); 47 46 48 var extraField = Doc.element('extraField'); 47 49 if (extraField == null) … … 66 68 67 69 if (window.Exception) Exception.fixWindow(); 70 } 71 72 login.switchLoginForm = function(event) 73 { 74 // TODO -- will not work when login form is in a different jsp 75 var url = 'main.jsp?ID='+App.getSessionId(); 76 url += '&loginForm='+event.currentTarget.value; 77 location.replace(url); 68 78 } 69 79 … … 192 202 } 193 203 204 alert(frm.loginForm.value); 205 194 206 // On the impersonate form, check that a user has been selected 195 207 if (frm.user_id && !frm.user_id.value) … … 204 216 Login.saveLastLogin(frm.login.value); 205 217 } 218 // TODO -- save the login form 206 219 207 220 // Check 'remain on page' and 'redirect' options … … 233 246 var frm2 = Forms.cloneAsHidden(frm); 234 247 document.body.appendChild(frm2); 248 alert(frm2.loginForm.value); 235 249 frm2.submit(); 236 250 document.body.removeChild(frm2); -
trunk/www/login.jsp
r7500 r7529 67 67 String deviceToken = Values.getStringOrNull(request.getParameter("deviceToken")); 68 68 String extraValue = Values.getStringOrNull(request.getParameter("extraField")); 69 String loginForm = Values.getStringOrNull(request.getParameter("loginForm")); 69 70 try 70 71 { … … 72 73 LoginRequest loginRequest = new LoginRequest(login, password, deviceToken); 73 74 if (extraValue != null) loginRequest.setAttribute("extraValue", extraValue); 75 if (loginForm != null) loginRequest.setAttribute("login-form", loginForm); 74 76 loginRequest.setAttribute("user-agent", request.getHeader("User-Agent")); 75 77 String serverUrl = request.getRequestURL().toString().replace(request.getRequestURI(), root); -
trunk/www/main.jsp
r7500 r7529 41 41 import="net.sf.basedb.core.query.Hql" 42 42 import="net.sf.basedb.util.extensions.ExtensionsInvoker" 43 import="net.sf.basedb.util.extensions.ActionIterator" 43 44 import="net.sf.basedb.clients.web.Base" 44 45 import="net.sf.basedb.clients.web.util.HTML" … … 53 54 import="net.sf.basedb.util.Values" 54 55 import="java.util.Date" 56 import="java.util.Map" 57 import="java.util.TreeMap" 55 58 %> 56 59 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 66 69 final String login = Values.getString(request.getParameter("login"), ""); 67 70 final String error = Values.getString(request.getParameter("error"), null); 71 final String requestedLoginForm = Values.getString(request.getParameter("loginForm"), null); 68 72 final String root = request.getContextPath()+"/"; 69 73 … … 83 87 84 88 LoginFormAction loginAction = null; 85 for (LoginFormAction action : invoker) 89 String selectedLoginForm = null; 90 Map<String, String> allForms = new TreeMap<String, String>(); 91 92 ActionIterator<LoginFormAction> it = invoker.iterate(); 93 while (it.hasNext()) 86 94 { 95 LoginFormAction action = it.next(); 87 96 if (action != null) 88 97 { 89 loginAction = action; 90 break; 98 String formId = action.getId(); 99 if (formId == null) formId = it.getExtension().getId(); 100 String displayName = action.getDisplayName(); 101 if (displayName == null) displayName = it.getExtension().getAbout().getName(); 102 allForms.put(formId, displayName); 103 104 if (loginAction == null || formId.equals(requestedLoginForm)) 105 { 106 loginAction = action; 107 selectedLoginForm = formId; 108 } 91 109 } 92 110 } … … 109 127 <ext:stylesheets context="<%=jspContext%>" /> 110 128 </base:head> 111 <base:body style="padding-top: 5em;" >129 <base:body style="padding-top: 5em;" data-login-form="<%=Values.getString(selectedLoginForm)%>"> 112 130 <form name="login" action="login.jsp" method="post"> 113 131 <input type="hidden" name="ID" value="<%=ID%>"> … … 122 140 { 123 141 %> 124 <div class="messagecontainer help" style=" font-style: italic;" id="login-help">142 <div class="messagecontainer help" style="margin-bottom: 1em; font-style: italic;" id="login-help"> 125 143 <%=loginAction.getHelp() %> 126 144 </div> … … 130 148 { 131 149 %> 132 <div class="messagecontainer error" style="margin-top: 1em;"><%=error%></div> 133 <% 134 } 135 %> 136 <table style="width: 100%; margin-top: 1em; border-collapse: separate;"> 150 <div class="messagecontainer error" style="margin-top: 1em; margin-bottom: 1em;"><%=error%></div> 151 <% 152 } 153 if (allForms.size() > 1) 154 { 155 %> 156 <div style="text-align: right; margin-bottom: 0.25em;"> 157 <b>Login with</b> 158 <select name="loginForm" id="loginForm" style="min-width: 10em;"> 159 <% 160 for (Map.Entry<String, String> entry : allForms.entrySet()) 161 { 162 String formId = entry.getKey(); 163 %> 164 <option value="<%=formId%>" <%=formId.equals(selectedLoginForm) ? "selected" : ""%>><%=HTML.encodeTags(entry.getValue()) %> 165 <% 166 } 167 %> 168 </select> 169 </div> 170 <% 171 } 172 else if (selectedLoginForm != null) 173 { 174 %> 175 <input type="hidden" name="loginForm" value="<%=selectedLoginForm%>"> 176 <% 177 } 178 %> 179 <table style="width: 100%; border-collapse: separate;"> 137 180 <tr> 138 181 <td class="base-logo"><img src="images/baselogo.png" alt="BASE logo"></td>
Note: See TracChangeset
for help on using the changeset viewer.