Skip to content

Commit 6828af9

Browse files
dragonpooludomikula
authored andcommitted
#1322: Added API: /email/bind
1 parent f23e901 commit 6828af9

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/AuthenticationController.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.lowcoder.api.authentication;
22

3-
import java.util.List;
4-
import java.util.Map;
5-
3+
import lombok.RequiredArgsConstructor;
64
import org.lowcoder.api.authentication.dto.APIKeyRequest;
75
import org.lowcoder.api.authentication.dto.AuthConfigRequest;
86
import org.lowcoder.api.authentication.service.AuthenticationApiService;
@@ -14,19 +12,18 @@
1412
import org.lowcoder.api.util.BusinessEventPublisher;
1513
import org.lowcoder.domain.authentication.FindAuthConfig;
1614
import org.lowcoder.domain.user.model.APIKey;
15+
import org.lowcoder.domain.user.service.UserService;
1716
import org.lowcoder.sdk.auth.AbstractAuthConfig;
18-
import org.lowcoder.sdk.auth.Oauth2GenericAuthConfig;
1917
import org.lowcoder.sdk.util.CookieHelper;
20-
import org.springframework.http.ResponseEntity;
2118
import org.springframework.web.bind.annotation.PathVariable;
2219
import org.springframework.web.bind.annotation.RequestBody;
2320
import org.springframework.web.bind.annotation.RequestParam;
2421
import org.springframework.web.bind.annotation.RestController;
2522
import org.springframework.web.server.ServerWebExchange;
26-
27-
import lombok.RequiredArgsConstructor;
2823
import reactor.core.publisher.Mono;
2924

25+
import java.util.List;
26+
3027
@RequiredArgsConstructor
3128
@RestController
3229
public class AuthenticationController implements AuthenticationEndpoints
@@ -36,6 +33,7 @@ public class AuthenticationController implements AuthenticationEndpoints
3633
private final SessionUserService sessionUserService;
3734
private final CookieHelper cookieHelper;
3835
private final BusinessEventPublisher businessEventPublisher;
36+
private final UserService userService;
3937

4038
/**
4139
* login by email or phone with password; or register by email for now.
@@ -130,4 +128,10 @@ public Mono<ResponseView<List<APIKey>>> getAllAPIKeys() {
130128
.collectList()
131129
.map(ResponseView::success);
132130
}
131+
132+
@Override
133+
public Mono<ResponseView<?>> bindEmail(@RequestParam String email) {
134+
return sessionUserService.getVisitor().flatMap(user -> userService.bindEmail(user, email))
135+
.map(ResponseView::success);
136+
}
133137
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/authentication/AuthenticationEndpoints.java

+9
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ public Mono<ResponseView<Boolean>> linkAccountWithThirdParty(
143143
@GetMapping("/api-keys")
144144
public Mono<ResponseView<List<APIKey>>> getAllAPIKeys();
145145

146+
@Operation(
147+
tags = TAG_AUTHENTICATION,
148+
operationId = "bindEmail",
149+
summary = "Bind current User to email",
150+
description = "Bind current user to email"
151+
)
152+
@PostMapping("/email/bind")
153+
public Mono<ResponseView<?>> bindEmail(@RequestParam String email);
154+
146155
/**
147156
* @param loginId phone number or email for now.
148157
* @param register register or login

0 commit comments

Comments
 (0)