Changeset 4918
- Timestamp:
- Aug 8, 2018, 2:20:30 PM (4 years ago)
- Location:
- extensions/net.sf.basedb.otp/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.otp/trunk/resources/css/otp.css
r4863 r4918 18 18 min-height: 70px; 19 19 } 20 21 #extra-row.optional td::after 22 { 23 content: "(optional)"; 24 opacity: 0.5; 25 } 26 27 #extra-row.required td::after 28 { 29 content: "(required)"; 30 opacity: 0.5; 31 } -
extensions/net.sf.basedb.otp/trunk/resources/scripts/login.js
r4863 r4918 7 7 otp.initPage = function() 8 8 { 9 var pwd = Doc.element('password'); 10 if (pwd.type == 'text') 9 // The OTP field can be either the password field or the 10 // extra field 11 var otpField = Doc.element('extraField'); 12 if (!otpField) otpField = Doc.element('password'); 13 // If the OTP field is text type, the user is not 14 // supposed to enter password into it 15 if (otpField.type == 'text') 11 16 { 12 17 // Limit to digits 13 Events.addEventHandler( pwd, 'keypress', Events.integerOnly);18 Events.addEventHandler(otpField, 'keypress', Events.integerOnly); 14 19 // Disable auto-complete 15 pwd.setAttribute('autocomplete', 'off');20 otpField.setAttribute('autocomplete', 'off'); 16 21 } 17 22 } -
extensions/net.sf.basedb.otp/trunk/src/net/sf/basedb/otp/Otp.java
r4851 r4918 131 131 return clientId != null && requireOtpLogin != null && requireOtpLogin.contains(clientId); 132 132 } 133 134 /** 135 Get the authentication method to use: 136 {@link #OTP_ONLY_AUTHENTICATION_METHOD} or 137 {@link #OTP_PASSWORD_AUTHENTICATION_METHOD}. 138 */ 139 public static AuthenticationMethod getAuthenticationMethod() 140 { 141 AuthenticationMethod am = OTP_PASSWORD_AUTHENTICATION_METHOD; 142 if ("otp-only".equals(getConfig().get("login-method"))) 143 { 144 am = OTP_ONLY_AUTHENTICATION_METHOD; 145 } 146 return am; 147 } 148 133 149 134 150 } -
extensions/net.sf.basedb.otp/trunk/src/net/sf/basedb/otp/OtpLoginFormFactory.java
r4863 r4918 5 5 import net.sf.basedb.clients.web.extensions.login.LoginFormAction; 6 6 import net.sf.basedb.clients.web.extensions.login.LoginFormBean; 7 import net.sf.basedb.core.authentication.AuthenticationMethod; 7 8 import net.sf.basedb.util.extensions.InvokationContext; 8 9 … … 18 19 19 20 private final boolean hasConfig; 21 private final AuthenticationMethod authMethod; 20 22 private final LoginFormBean loginFormOptional; 21 23 private final LoginFormBean loginFormRequired; … … 25 27 { 26 28 hasConfig = Otp.getConfig() != null; 29 authMethod = Otp.getAuthenticationMethod(); 30 31 FieldInfo otpOrPasswordField = new FieldInfo("OTP or password", true); 32 otpOrPasswordField.setStyle("width: 10em;"); 33 otpOrPasswordField.setTooltip("Use your device to generate a 6-digit passcode (or use the regular password)"); 34 35 FieldInfo otpFieldRequired = new FieldInfo("One-time passcode", false); 36 otpFieldRequired.setClazz("requried"); 37 otpFieldRequired.setStyle("width: 10em;"); 38 otpFieldRequired.setTooltip("Use your device to generate a 6-digit code (required)"); 39 40 FieldInfo otpFieldOptional = new FieldInfo("One-time passcode", false); 41 otpFieldOptional.setClazz("optional"); 42 otpFieldOptional.setStyle("width: 10em;"); 43 otpFieldOptional.setTooltip("Use your device to generate a 6-digit code (optional)"); 44 45 String helpTextWithConfigLink = "<p style=\"margin-top: 0.5em;\">" 46 + "<b>Note!</b> If you have not configured your account for OTP you can do it " 47 + "<span class=\"link auto-init\" data-auto-init=\"setup-otp\">here</span>."; 27 48 28 49 loginFormOptional = new LoginFormBean(); 29 50 loginFormOptional.setRememberLastLogin(true); 30 loginFormOptional.setHelp( 51 loginFormOptional.setLoginField(FieldInfo.DEFAULT_LOGIN); 52 if (authMethod == Otp.OTP_ONLY_AUTHENTICATION_METHOD) 53 { 54 loginFormOptional.setHelp( 31 55 "If you have set-up your account for one-time passwords (OTP), use your device to generate a " 32 56 + "6-digit passcode. Enter your username in the <b>Login</b> field and the code in the <b>OTP or password</b> field. " 33 + "<p style=\"margin-top: 0.5em;\">" 34 + "<b>Note!</b> If you have not configured your account for OTP you can do it <span class=\"link auto-init\" data-auto-init=\"setup-otp\">here</span>."); 35 36 FieldInfo otpFieldOptional = new FieldInfo("OTP or password", true); 37 otpFieldOptional.setStyle("width: 10em;"); 38 otpFieldOptional.setTooltip("Use your device to generate a 6-digit passcode (or use the regular password)"); 39 40 loginFormOptional.setLoginField(FieldInfo.DEFAULT_LOGIN); 41 loginFormOptional.setPasswordField(otpFieldOptional); 57 + helpTextWithConfigLink); 58 loginFormOptional.setPasswordField(otpOrPasswordField); 59 } 60 else 61 { 62 loginFormOptional.setHelp( 63 "If you have set-up your account for one-time passwords (OTP), use your device to generate a " 64 + "6-digit passcode. Enter your username in the <b>Login</b> field, your regular password in " 65 + "the <b>Password</b> field and the code in the <b>One-time passcode</b> field. " 66 + helpTextWithConfigLink); 67 loginFormOptional.setPasswordField(FieldInfo.DEFAULT_PASSWORD); 68 loginFormOptional.setExtraField(otpFieldOptional); 69 } 42 70 43 71 loginFormRequired = new LoginFormBean(); 44 72 loginFormRequired.setRememberLastLogin(true); 45 loginFormRequired.setHelp( 73 loginFormRequired.setLoginField(FieldInfo.DEFAULT_LOGIN); 74 if (authMethod == Otp.OTP_ONLY_AUTHENTICATION_METHOD) 75 { 76 loginFormRequired.setHelp( 46 77 "A one-time passcode (OTP) is required to login. Enter your username in the <b>Login</b> field. " 47 78 + "Use your device to generate a 6-digit code and enter it in the <b>One-time passcode</b> field. " 48 + "<p style=\"margin-top: 0.5em;\">" 49 + "<b>Note!</b> If you have not configured your account for OTP you can do it <span class=\"link auto-init\" data-auto-init=\"setup-otp\">here</span>."); 50 51 FieldInfo otpFieldRequired = new FieldInfo("One-time passcode", false); 52 otpFieldRequired.setStyle("width: 10em;"); 53 otpFieldRequired.setTooltip("Use your device to generate a 6-digit code"); 54 55 loginFormRequired.setLoginField(FieldInfo.DEFAULT_LOGIN); 56 loginFormRequired.setPasswordField(otpFieldRequired); 79 + helpTextWithConfigLink); 80 loginFormRequired.setPasswordField(otpFieldRequired); 81 } 82 else 83 { 84 loginFormRequired.setHelp( 85 "A one-time passcode (OTP) is required to login. Enter your username in the <b>Login</b> field and your " 86 + "regular password in the <b>Password</b> field. " 87 + "Use your device to generate a 6-digit code and enter it in the <b>One-time passcode</b> field. " 88 + helpTextWithConfigLink); 89 loginFormRequired.setPasswordField(FieldInfo.DEFAULT_PASSWORD); 90 loginFormRequired.setExtraField(otpFieldRequired); 91 } 57 92 } 58 93
Note: See TracChangeset
for help on using the changeset viewer.