Changeset 7816
- Timestamp:
- Jun 5, 2020, 1:10:03 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Install.java
r7813 r7816 118 118 method. 119 119 */ 120 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(14 7).intValue();120 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(148).intValue(); 121 121 122 122 public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress, -
trunk/src/core/net/sf/basedb/core/SessionControl.java
r7815 r7816 432 432 433 433 UserDeviceData device = null; 434 boolean needToVerifyDevice = false; 434 435 AuthenticatedUser authUser = null; 435 436 UserData user = null; … … 463 464 464 465 // The login was ok so far... check device verification 465 device = verifyDevice(session, loginRequest, authUser); 466 device = loadDevice(session, loginRequest, authUser); 467 needToVerifyDevice = device != null && !device.isVerified() && user.getUseDeviceVerification() && EmailUtil.isEnabled(); 466 468 467 // A null value means that either device verification is disabled468 // An existing device means that it is already registered (TODO - check if verification is needed!!)469 469 LoginInfo li = null; 470 if ( device == null || device.getId() != 0)470 if (!needToVerifyDevice) 471 471 { 472 472 // All is ok, finalize the login … … 496 496 } 497 497 498 if ( device != null && device.getId() == 0)498 if (needToVerifyDevice) 499 499 { 500 500 // Device verification is enabled and the user is using an unverified device … … 595 595 LoginRequest loginRequest = unverifiedDeviceInfo.loginRequest; 596 596 AuthenticatedUser authUser = unverifiedDeviceInfo.authenticatedUser; 597 598 int deviceId = 0; 597 int deviceId = unverifiedDeviceInfo.device.getId(); 599 598 if (rememberDevice) 600 599 { 601 HibernateUtil.saveData(session, unverifiedDeviceInfo.device); 602 deviceId = unverifiedDeviceInfo.device.getId(); 600 HibernateUtil.loadData(session, UserDeviceData.class, deviceId).setVerified(true); 603 601 } 604 602 … … 814 812 @return An {@link UserDeviceData} object if device verification is 815 813 supported and needed, null to continue with normal login 816 @since 3.12 817 */ 818 private UserDeviceData verifyDevice(org.hibernate.Session session, LoginRequest loginRequest, AuthenticatedUser authUser)814 @since 3.12, 3.17 815 */ 816 private UserDeviceData loadDevice(org.hibernate.Session session, LoginRequest loginRequest, AuthenticatedUser authUser) 819 817 { 820 818 // Check the submitted deviceToken … … 874 872 device.setToken(deviceToken); 875 873 device.setUserAgent(userAgent); 874 device.setVerified(false); 876 875 } 877 876 … … 884 883 device.setLocationLatitude(loc.getLatitude()); 885 884 device.setLocationLongitude(loc.getLongitude()); 886 887 // If this is a new or unverified device we check if it needs to be verified 888 if (device.getId() == 0) 889 { 890 if (user.getUseDeviceVerification() && EmailUtil.isEnabled()) 891 { 892 // The device need verification so we do not save it 893 // TODO -- will not work correctly if we add device.isVerified() flag 894 } 895 else 896 { 897 HibernateUtil.saveData(session, device); 898 } 899 } 885 886 if (device.getId() == 0) HibernateUtil.saveData(session, device); 900 887 901 888 return device; -
trunk/src/core/net/sf/basedb/core/Update.java
r7703 r7816 434 434 </td> 435 435 </tr> 436 <tr> 437 <td>148</td> 438 <td> 439 Added {@link UserDeviceData#isVerified()}. 440 The update will set the value to TRUE for all existing devices. 441 </td> 442 </tr> 436 443 </table> 437 444 … … 709 716 if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 147..."); 710 717 schemaVersion = updateToSchemaVersion147(session, schemaVersion); 718 progress_current += progress_step; 719 } 720 721 if (schemaVersion < 148) 722 { 723 if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 148..."); 724 schemaVersion = setSchemaVersionInTransaction(session, 148); 711 725 progress_current += progress_step; 712 726 } … … 1072 1086 "SET at.identifier = false " + 1073 1087 "WHERE at.identifier IS NULL"); 1088 query.executeUpdate(); 1089 } 1090 1091 if (schemaVersion < 148) 1092 { 1093 // Set is_verified=true on all registered devices 1094 org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session, 1095 "UPDATE UserDeviceData ud " + 1096 "SET ud.verified = true " + 1097 "WHERE ud.verified = false"); 1074 1098 query.executeUpdate(); 1075 1099 } -
trunk/src/core/net/sf/basedb/core/UserDevice.java
r7413 r7816 261 261 return getData().getLocationLongitude(); 262 262 } 263 264 /** 265 Has this device been verified or not? Verification is done 266 by requesting a code via email. 267 @since 3.17 268 */ 269 public boolean isVerified() 270 { 271 return getData().isVerified(); 272 } 263 273 264 274 } -
trunk/src/core/net/sf/basedb/core/data/UserDeviceData.java
r7461 r7816 236 236 } 237 237 238 private boolean isVerified; 239 /** 240 This flag is TRUE if the device has been verified (by sending a code via email). 241 @since 3.17 242 Mapped in hibernate-properties-UserDeviceData.xml since default is not supported in XDoclet 243 //hibernate.property column="`is_verified`" type="boolean" not-null="true" default="false" 244 */ 245 public boolean isVerified() 246 { 247 return isVerified; 248 } 249 public void setVerified(boolean isVerified) 250 { 251 this.isVerified = isVerified; 252 } 253 238 254 private Set<SessionData> sessions; 239 255 /** -
trunk/www/views/devices/index.jsp
r7605 r7816 62 62 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 63 63 <%! 64 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,client, lastUsed,lastRemoteId,location,description");64 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,client,verified,lastUsed,lastRemoteId,location,description"); 65 65 private static final Item itemType = Item.USERDEVICE; 66 66 %> -
trunk/www/views/devices/list_devices.jsp
r7604 r7816 185 185 exportable="true" 186 186 formatter="<%=dateFormatter%>" 187 /> 188 <tbl:columndef 189 id="verified" 190 property="verified" 191 datatype="boolean" 192 title="Is verified" 193 sortable="true" 194 filterable="true" 195 exportable="true" 187 196 /> 188 197 <tbl:columndef … … 413 422 <tbl:cell column="userAgent"><%=HTML.encodeTags(item.getUserAgent())%></tbl:cell> 414 423 <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" /> 424 <tbl:cell column="verified" value="<%=item.isVerified() ? "Yes" : "No"%>" /> 415 425 <tbl:cell column="lastUsed" value="<%=item.getLastUsed()%>" /> 416 426 <tbl:cell column="lastRemoteId"><%=HTML.encodeTags(item.getLastRemoteId())%></tbl:cell> -
trunk/www/views/devices/view_device.jsp
r7604 r7816 157 157 </tr> 158 158 <tr> 159 <th>Verified</th> 160 <td><%=device.isVerified() ? "Yes" : "No"%></td> 161 </tr> 162 <tr> 159 163 <th>Registered</th> 160 164 <td><%=dateFormatter.format(device.getEntryDate())%></td>
Note: See TracChangeset
for help on using the changeset viewer.