Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allow Email/Form Login/Register To Bind User To Org On Login/SignUp#522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,9 +12,10 @@ public class FormAuthRequestContext extends AuthRequestContext {
privatefinalStringpassword;
privatefinalbooleanregister;

publicFormAuthRequestContext(StringloginId,Stringpassword,booleanregister) {
publicFormAuthRequestContext(StringloginId,Stringpassword,booleanregister,StringorgId) {
this.loginId =loginId;
this.password =password;
this.register =register;
this.setOrgId(orgId);
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,10 +41,11 @@ public class AuthenticationController implements AuthenticationEndpoints
*/
@Override
public Mono<ResponseView<Boolean>> formLogin(@RequestBody FormLoginRequest formLoginRequest,
@RequestParam(required = false) String invitationId,
ServerWebExchange exchange) {
@RequestParam(required = false) String invitationId,
@RequestParam(required = false) String orgId,
ServerWebExchange exchange) {
return authenticationApiService.authenticateByForm(formLoginRequest.loginId(), formLoginRequest.password(),
formLoginRequest.source(), formLoginRequest.register(), formLoginRequest.authId())
formLoginRequest.source(), formLoginRequest.register(), formLoginRequest.authId(), orgId)
.flatMap(user -> authenticationApiService.loginOrRegister(user, exchange, invitationId))
.thenReturn(ResponseView.success(true));
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,6 +47,7 @@ public interface AuthenticationEndpoints
@PostMapping("/form/login")
public Mono<ResponseView<Boolean>> formLogin(@RequestBody FormLoginRequest formLoginRequest,
@RequestParam(required = false) String invitationId,
@RequestParam(required = false) String orgId,
ServerWebExchange exchange);

/**
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@

publicinterfaceAuthenticationApiService {

Mono<AuthUser>authenticateByForm(StringloginId,Stringpassword,Stringsource,booleanregister,StringauthId);
Mono<AuthUser>authenticateByForm(StringloginId,Stringpassword,Stringsource,booleanregister,StringauthId,StringorgId);

Mono<AuthUser>authenticateByOauth2(StringauthId,Stringsource,Stringcode,StringredirectUrl,StringorgId);

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,8 +86,8 @@ public class AuthenticationApiServiceImpl implements AuthenticationApiService {
private JWTUtils jwtUtils;

@Override
public Mono<AuthUser> authenticateByForm(String loginId, String password, String source, boolean register, String authId) {
return authenticate(authId, source, new FormAuthRequestContext(loginId, password, register));
public Mono<AuthUser> authenticateByForm(String loginId, String password, String source, boolean register, String authId, String orgId) {
return authenticate(authId, source, new FormAuthRequestContext(loginId, password, register, orgId));
}

@Override
Expand All@@ -105,7 +105,13 @@ protected Mono<AuthUser> authenticate(String authId, @Deprecated String source,
})
.doOnNext(findAuthConfig -> {
context.setAuthConfig(findAuthConfig.authConfig());
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
if (findAuthConfig.authConfig().getSource().equals("EMAIL")) {
if(StringUtils.isBlank(context.getOrgId())) {
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
}
} else {
context.setOrgId(Optional.ofNullable(findAuthConfig.organization()).map(Organization::getId).orElse(null));
}
})
.then(authRequestFactory.build(context))
.flatMap(authRequest -> authRequest.auth(context))
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,7 +64,7 @@ public void testFormRegisterSuccess() {
MockServerHttpRequest request = MockServerHttpRequest.post("").build();
MockServerWebExchange exchange = MockServerWebExchange.builder(request).build();

Mono<User> userMono = authenticationController.formLogin(formLoginRequest, null, exchange)
Mono<User> userMono = authenticationController.formLogin(formLoginRequest, null,null,exchange)
.then(userRepository.findByConnections_SourceAndConnections_RawId(source, email));

StepVerifier.create(userMono)
Expand DownExpand Up@@ -115,8 +115,8 @@ public void testFormLoginSuccess() {
MockServerHttpRequest loginRequest = MockServerHttpRequest.post("").build();
MockServerWebExchange loginExchange = MockServerWebExchange.builder(loginRequest).build();

Mono<User> userMono = authenticationController.formLogin(formRegisterRequest, null, registerExchange)
.then(authenticationController.formLogin(formLoginRequest, null, loginExchange))
Mono<User> userMono = authenticationController.formLogin(formRegisterRequest, null,null, registerExchange)
.then(authenticationController.formLogin(formLoginRequest, null,null,loginExchange))
.then(userRepository.findByConnections_SourceAndConnections_RawId(source, email));

StepVerifier.create(userMono)
Expand DownExpand Up@@ -163,8 +163,8 @@ public void testRegisterFailByLoginIdExist() {
MockServerHttpRequest request = MockServerHttpRequest.post("").build();
MockServerWebExchange exchange = MockServerWebExchange.builder(request).build();

Mono<ResponseView<Boolean>> loginMono = authenticationController.formLogin(formLoginRequest, null, exchange)
.then(authenticationController.formLogin(formLoginRequest, null, exchange));
Mono<ResponseView<Boolean>> loginMono = authenticationController.formLogin(formLoginRequest, null,null,exchange)
.then(authenticationController.formLogin(formLoginRequest, null,null, exchange));
StepVerifier.create(loginMono)
.verifyErrorMatches(throwable -> {
BizException bizException = (BizException) throwable;
Expand All@@ -184,7 +184,7 @@ public void testLoginFailByLoginIdNotExist() {
MockServerHttpRequest request = MockServerHttpRequest.post("").build();
MockServerWebExchange exchange = MockServerWebExchange.builder(request).build();

Mono<ResponseView<Boolean>> loginMono = authenticationController.formLogin(formLoginRequest, null, exchange);
Mono<ResponseView<Boolean>> loginMono = authenticationController.formLogin(formLoginRequest, null,null,exchange);
StepVerifier.create(loginMono)
.verifyErrorMatches(throwable -> {
BizException bizException = (BizException) throwable;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ public void testGoogleRegisterSuccess() {
MockServerHttpRequestrequest =MockServerHttpRequest.post("").build();
MockServerWebExchangeexchange =MockServerWebExchange.builder(request).build();

Mono<User>userMono =authenticationController.formLogin(formLoginRequest,null,exchange)
Mono<User>userMono =authenticationController.formLogin(formLoginRequest,null,null,exchange)
.then(userRepository.findByConnections_SourceAndConnections_RawId(source,email));

StepVerifier.create(userMono)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp