Remove unused API endpoints for invite confirmation (#2532)
This commit is contained in:
parent
88e8723f37
commit
e4ba991114
|
|
@ -111,19 +111,6 @@ public class UserController extends BaseController<UserService, User, String> {
|
|||
.map(user -> new ResponseDTO<>(HttpStatus.OK.value(), user, null));
|
||||
}
|
||||
|
||||
@GetMapping("/invite/verify")
|
||||
public Mono<ResponseDTO<Boolean>> verifyInviteToken(@RequestParam String email, @RequestParam String token) {
|
||||
return service.verifyInviteToken(email, token)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.OK.value(), result, null));
|
||||
}
|
||||
|
||||
@PutMapping("/invite/confirm")
|
||||
public Mono<ResponseDTO<Boolean>> confirmInviteUser(@RequestBody User inviteUser,
|
||||
@RequestHeader("Origin") String originHeader) {
|
||||
return service.confirmInviteUser(inviteUser, originHeader)
|
||||
.map(result -> new ResponseDTO<>(HttpStatus.OK.value(), result, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates an invite for new users to join an Appsmith organization. We require the Origin header
|
||||
* in order to construct client facing URLs that will be sent to the users via email.
|
||||
|
|
|
|||
|
|
@ -22,10 +22,6 @@ public interface UserService extends CrudService<User, String> {
|
|||
|
||||
Mono<User> inviteUserToApplication(InviteUser inviteUser, String originHeader, String applicationId);
|
||||
|
||||
Mono<Boolean> verifyInviteToken(String email, String token);
|
||||
|
||||
Mono<Boolean> confirmInviteUser(User inviteUser, String originHeader);
|
||||
|
||||
Mono<User> createUserAndSendEmail(User user, String originHeader);
|
||||
|
||||
Mono<User> userCreate(User user);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ import static com.appsmith.server.acl.AclPermission.USER_MANAGE_ORGANIZATIONS;
|
|||
public class UserServiceImpl extends BaseService<UserRepository, User, String> implements UserService {
|
||||
|
||||
private final OrganizationService organizationService;
|
||||
private final AnalyticsService analyticsService;
|
||||
private final SessionUserService sessionUserService;
|
||||
private final PasswordResetTokenRepository passwordResetTokenRepository;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
|
@ -102,7 +101,6 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
|||
CommonConfig commonConfig) {
|
||||
super(scheduler, validator, mongoConverter, reactiveMongoTemplate, repository, analyticsService);
|
||||
this.organizationService = organizationService;
|
||||
this.analyticsService = analyticsService;
|
||||
this.sessionUserService = sessionUserService;
|
||||
this.passwordResetTokenRepository = passwordResetTokenRepository;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
|
|
@ -365,61 +363,6 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> i
|
|||
return userMono;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks if the inviteToken is valid for the user. If the token is incorrect or it as expired,
|
||||
* the client should show the appropriate message to the user
|
||||
*
|
||||
* @param email
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Mono<Boolean> verifyInviteToken(String email, String token) {
|
||||
log.debug("Verifying token: {} for email: {}", token, email);
|
||||
return repository.findByEmail(email)
|
||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "email", email)))
|
||||
.flatMap(inviteUser -> passwordEncoder.matches(token, inviteUser.getInviteToken()) ?
|
||||
Mono.just(true) : Mono.just(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function confirms the signup for a new invited user. Primarily it will be used to set the password
|
||||
* for the user and set the user to enabled. The user should have been created during the invite flow.
|
||||
*
|
||||
* @param inviteUser
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Mono<Boolean> confirmInviteUser(User inviteUser, String originHeader) {
|
||||
|
||||
if (inviteUser.getEmail() == null || inviteUser.getEmail().isEmpty()) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "email"));
|
||||
}
|
||||
|
||||
if (inviteUser.getPassword() == null || inviteUser.getPassword().isEmpty()) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "password"));
|
||||
}
|
||||
|
||||
log.debug("Confirming the signup for the user: {} and token: {}", inviteUser.getEmail(), inviteUser.getInviteToken());
|
||||
|
||||
inviteUser.setPassword(this.passwordEncoder.encode(inviteUser.getPassword()));
|
||||
|
||||
return repository.findByEmail(inviteUser.getEmail())
|
||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "email", inviteUser.getEmail())))
|
||||
.flatMap(newUser -> {
|
||||
|
||||
// Activate the user now :
|
||||
newUser.setIsEnabled(true);
|
||||
newUser.setPassword(inviteUser.getPassword());
|
||||
// The user has now been invited and has signed up. Delete the invite token because its no longer required
|
||||
newUser.setInviteToken(null);
|
||||
|
||||
return repository.save(newUser)
|
||||
.map(savedUser -> sendWelcomeEmail(savedUser, originHeader))
|
||||
.thenReturn(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<User> create(User user) {
|
||||
// This is the path that is taken when a new user signs up on its own
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user