File tree Expand file tree Collapse file tree 4 files changed +28
-9
lines changed
main/java/org/woehlke/java/simpleworklist/domain/db/user
test/java/org/woehlke/java/simpleworklist/domain/db/user Expand file tree Collapse file tree 4 files changed +28
-9
lines changed Original file line number Diff line number Diff line change 640640 <artifactId >antlr-runtime</artifactId >
641641 <version >3.5.3</version >
642642 </dependency >
643+ <dependency >
644+ <groupId >org.antlr</groupId >
645+ <artifactId >antlr4-runtime</artifactId >
646+ <version >4.11.1</version >
647+ <scope >runtime</scope >
648+ </dependency >
643649 </dependencies >
644650 </dependencyManagement >
645651
11041110 <groupId >org.antlr</groupId >
11051111 <artifactId >antlr-runtime</artifactId >
11061112 </dependency >
1107- <!--
11081113 <dependency >
11091114 <groupId >org.antlr</groupId >
11101115 <artifactId >antlr4-runtime</artifactId >
1111- <scope>provided </scope>
1116+ <scope >runtime </scope >
11121117 </dependency >
1113- -->
11141118 </dependencies >
11151119
11161120 <build >
Original file line number Diff line number Diff line change 1313import org .woehlke .java .simpleworklist .domain .db .user .UserAccountPasswordRecovery ;
1414import org .woehlke .java .simpleworklist .domain .db .user .token .TokenGeneratorService ;
1515
16+ import java .time .LocalDateTime ;
17+ import java .time .ZoneId ;
18+ import java .time .ZoneOffset ;
1619import java .util .Date ;
1720import java .util .UUID ;
1821
@@ -49,8 +52,10 @@ public boolean passwordRecoveryIsRetryAndMaximumNumberOfRetries(String email) {
4952 public void passwordRecoveryCheckIfResponseIsInTime (String email ) {
5053 UserAccountPasswordRecovery earlierOptIn = userAccountPasswordRecoveryRepository .findByEmail (email );
5154 if (earlierOptIn != null ) {
52- Date now = new Date ();
53- if ((simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest () + earlierOptIn .getRowCreatedAt ().getTime ()) < now .getTime ()) {
55+ ZoneId zone = ZoneId .systemDefault ();
56+ ZoneOffset offset = ZoneOffset .UTC ;
57+ LocalDateTime now = LocalDateTime .now (zone );
58+ if ((simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest () + earlierOptIn .getRowCreatedAt ().toEpochSecond (offset )) < now .toEpochSecond (offset )) {
5459 userAccountPasswordRecoveryRepository .delete (earlierOptIn );
5560 }
5661 }
Original file line number Diff line number Diff line change 11package org .woehlke .java .simpleworklist .domain .db .user .signup ;
22
3+ import java .time .LocalDateTime ;
4+ import java .time .ZoneId ;
5+ import java .time .ZoneOffset ;
36import java .util .Date ;
47import java .util .UUID ;
58
@@ -52,9 +55,11 @@ public boolean registrationIsRetryAndMaximumNumberOfRetries(String email) {
5255 public void registrationCheckIfResponseIsInTime (String email ) {
5356 UserAccountRegistration earlierOptIn = userAccountRegistrationRepository .findByEmail (email );
5457 if (earlierOptIn != null ) {
55- Date now = new Date ();
58+ ZoneId zone = ZoneId .systemDefault ();
59+ ZoneOffset offset = ZoneOffset .UTC ;
60+ LocalDateTime now = LocalDateTime .now (zone );
5661 if ((simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest ()
57- + earlierOptIn .getRowCreatedAt ().getTime ( )) < now .getTime ( )) {
62+ + earlierOptIn .getRowCreatedAt ().toEpochSecond ( offset )) < now .toEpochSecond ( offset )) {
5863 userAccountRegistrationRepository .delete (earlierOptIn );
5964 }
6065 }
Original file line number Diff line number Diff line change 1818import org .springframework .beans .factory .annotation .Autowired ;
1919import org .woehlke .java .simpleworklist .domain .db .user .signup .UserAccountRegistrationService ;
2020
21+ import java .time .LocalDateTime ;
22+ import java .time .ZoneId ;
23+ import java .time .ZoneOffset ;
2124import java .util .Date ;
2225import java .util .UUID ;
2326
@@ -113,7 +116,8 @@ public void testCheckIfResponseIsInTimeNewUser(){
113116 UserAccountRegistration o = testHelperService .findRegistrationByEmail (emails [0 ]);
114117 //assertNull(o);
115118 assertNotNull (o );
116- o .setRowCreatedAt (new Date (o .getRowCreatedAt ().getTime () - simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest ()));
119+ LocalDateTime a = o .getRowCreatedAt ().minusSeconds (simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest ());
120+ o .setRowCreatedAt (a );
117121 o .setNumberOfRetries (0 );
118122 userAccountRegistrationService .registrationClickedInEmail (o );
119123 userAccountRegistrationService .registrationCheckIfResponseIsInTime (emails [0 ]);
@@ -133,7 +137,8 @@ public void testCheckIfResponseIsInTime(){
133137 userAccountPasswordRecoveryService .passwordRecoveryCheckIfResponseIsInTime (emails [0 ]);
134138 UserAccountPasswordRecovery o = testHelperService .findPasswordRecoveryByEmail (emails [0 ]);
135139 assertNotNull (o );
136- o .setRowCreatedAt (new Date (o .getRowCreatedAt ().getTime () - simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest ()));
140+ LocalDateTime a = o .getRowCreatedAt ().minusSeconds (simpleworklistProperties .getRegistration ().getTtlEmailVerificationRequest ());
141+ o .setRowCreatedAt (a );
137142 o .setNumberOfRetries (0 );
138143 userAccountPasswordRecoveryService .passwordRecoveryClickedInEmail (o );
139144 userAccountPasswordRecoveryService .passwordRecoveryCheckIfResponseIsInTime (emails [0 ]);
You can’t perform that action at this time.
0 commit comments