From 68092c19cc00a5adedc59d0b2fabec77501cb6cf Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Fri, 3 Jan 2020 20:15:23 +0530 Subject: [PATCH] Ensuring that a user's personal workspace name is their first name by default. This is because the full name makes the entire workspace name very long. If we just use the first name, it'll be a shorter string and easier to read by the end user as well. --- .../configurations/ClientUserRepository.java | 19 ------------------- .../server/services/UserServiceImpl.java | 11 +++++++---- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/ClientUserRepository.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/ClientUserRepository.java index b99cf69198..5b8c4277f6 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/ClientUserRepository.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/ClientUserRepository.java @@ -107,25 +107,6 @@ public class ClientUserRepository implements ServerOAuth2AuthorizedClientReposit .then(Mono.empty()); } - public Mono checkAndCreateUser(OidcUser user) { - User newUser = new User(); - newUser.setName(user.getFullName()); - newUser.setEmail(user.getEmail()); - newUser.setSource(LoginSource.GOOGLE); - newUser.setState(UserState.ACTIVATED); - newUser.setIsEnabled(true); - // TODO: Check if this is a valid permission available in the DB - // TODO: Check to see if this user was invited or is it a new sign up - Set permissions = new HashSet<>(); - // Adding the create organization permission because this is a new user and we will have to create an organization - // after this for the user. - permissions.addAll(AclConstants.PERMISSIONS_CRUD_ORG); - newUser.setPermissions(permissions); - - return userService.findByEmail(user.getEmail()) - .switchIfEmpty(Mono.defer(() -> userService.create(newUser))); //In case the user doesn't exist, create and save the user. - } - @Override public Mono removeAuthorizedClient(String clientRegistrationId, Authentication principal, ServerWebExchange exchange) { diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java index bc857a7c8f..44763b9aaa 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/UserServiceImpl.java @@ -423,13 +423,16 @@ public class UserServiceImpl extends BaseService i } Organization personalOrg = new Organization(); - String name; + String firstName; if (user.getName() != null) { - name = user.getName(); + // Get the first word from the full name and assume that that's the user's first name + firstName = user.getName().split(" ")[0]; } else { - name = user.getEmail(); + user.setName(user.getEmail()); + firstName = user.getEmail().split("@")[0]; } - String personalWorkspaceName = name + "'s Personal Workspace"; + + String personalWorkspaceName = firstName + "'s Personal Workspace"; personalOrg.setName(personalWorkspaceName); Mono savedOrganizationMono = organizationService.create(personalOrg);