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.
This commit is contained in:
Arpit Mohan 2020-01-03 20:15:23 +05:30
parent 677b13cf89
commit 68092c19cc
2 changed files with 7 additions and 23 deletions

View File

@ -107,25 +107,6 @@ public class ClientUserRepository implements ServerOAuth2AuthorizedClientReposit
.then(Mono.empty());
}
public Mono<User> 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<String> 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<Void> removeAuthorizedClient(String clientRegistrationId, Authentication principal,
ServerWebExchange exchange) {

View File

@ -423,13 +423,16 @@ public class UserServiceImpl extends BaseService<UserRepository, User, String> 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<Organization> savedOrganizationMono = organizationService.create(personalOrg);