File tree Expand file tree Collapse file tree 5 files changed +31
-0
lines changed
lowcoder-domain/src/main/java/org/lowcoder/domain/user/service
lowcoder-server/src/main/java/org/lowcoder/api/usermanagement Expand file tree Collapse file tree 5 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ public interface UserService {
5050
5151 Mono <String > resetPassword (String userId );
5252
53+ Mono <String > lostPassword (String userEmail );
54+
5355 Mono <Boolean > setPassword (String userId , String password );
5456
5557 Mono <UserDetail > buildUserDetail (User user , boolean withoutDynamicGroups );
Original file line number Diff line number Diff line change 4040
4141import javax .annotation .Nonnull ;
4242import java .security .SecureRandom ;
43+ import java .time .Duration ;
44+ import java .time .LocalDate ;
4345import java .util .*;
4446import java .util .function .Function ;
4547import java .util .stream .Collectors ;
@@ -262,6 +264,14 @@ public Mono<String> resetPassword(String userId) {
262264 });
263265 }
264266
267+ @ Override
268+ public Mono <String > lostPassword (String userEmail ) {
269+ return findByName (userEmail )
270+ .flatMap (user -> {
271+ return Mono .justOrEmpty (user .getName ());
272+ });
273+ }
274+
265275 @ SuppressWarnings ("SpellCheckingInspection" )
266276 @ Nonnull
267277 private static String generateNewRandomPwd () {
Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ public Mono<String> resetPassword(String userId) {
6565 .then (userService .resetPassword (userId ));
6666 }
6767
68+ public Mono <String > lostPassword (String userEmail ) {
69+ return userService .lostPassword (userEmail );
70+ }
71+
6872 // ========================== TOKEN OPERATIONS START ==========================
6973
7074 public Mono <Void > saveToken (String userId , String source , String token ) {
Original file line number Diff line number Diff line change @@ -146,6 +146,15 @@ public Mono<ResponseView<String>> resetPassword(@RequestBody ResetPasswordReques
146146
147147 }
148148
149+ @ Override
150+ public Mono <ResponseView <String >> lostPassword (@ RequestBody LostPasswordRequest request ) {
151+ if (StringUtils .isBlank (request .userEmail ())) {
152+ return ofError (BizError .INVALID_PARAMETER , "INVALID_USER_EMAIL" );
153+ }
154+ return userApiService .lostPassword (request .userEmail ())
155+ .map (ResponseView ::success );
156+ }
157+
149158 @ Override
150159 public Mono <ResponseView <Boolean >> setPassword (@ RequestParam String password ) {
151160 if (StringUtils .isBlank (password )) {
Original file line number Diff line number Diff line change @@ -121,6 +121,9 @@ public interface UserEndpoints
121121 @ PostMapping ("/reset-password" )
122122 public Mono <ResponseView <String >> resetPassword (@ RequestBody ResetPasswordRequest request );
123123
124+ @ PostMapping ("/lost-password" )
125+ public Mono <ResponseView <String >> lostPassword (@ RequestBody LostPasswordRequest userEmail );
126+
124127 @ Operation (
125128 tags = TAG_USER_PASSWORD_MANAGEMENT ,
126129 operationId = "setPassword" ,
@@ -151,6 +154,9 @@ public interface UserEndpoints
151154 public record ResetPasswordRequest (String userId ) {
152155 }
153156
157+ public record LostPasswordRequest (String userEmail ) {
158+ }
159+
154160 public record UpdatePasswordRequest (String oldPassword , String newPassword ) {
155161 }
156162
You can’t perform that action at this time.
0 commit comments