Migrate NameHash (#17317)

This commit is contained in:
Mohit Yadav 2024-08-06 18:41:37 +05:30 committed by GitHub
parent 21120a0130
commit 9bbc6a1801
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View File

@ -19,3 +19,5 @@ SET json = JSON_SET(
'$.fullyQualifiedName',
LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.fullyQualifiedName')))
);
UPDATE user_entity SET nameHash = MD5(JSON_UNQUOTE(JSON_EXTRACT(json, '$.fullyQualifiedName')));

View File

@ -18,4 +18,6 @@ SET json = jsonb_set(
json,
'{fullyQualifiedName}',
to_jsonb(LOWER(json->>'fullyQualifiedName'))
);
);
UPDATE user_entity SET nameHash = MD5(json ->> 'fullyQualifiedName');

View File

@ -568,14 +568,14 @@ public class UserResource extends EntityResource<User, UserRepository> {
@Context ContainerRequestContext containerRequestContext,
@Valid CreateUser create) {
User user = getUser(securityContext.getUserPrincipal().getName(), create);
if (Boolean.TRUE.equals(create.getIsBot())) {
if (Boolean.TRUE.equals(user.getIsBot())) {
addAuthMechanismToBot(user, create, uriInfo);
}
//
try {
// Email Validation
validateEmailAlreadyExists(create.getEmail());
validateEmailAlreadyExists(user.getEmail());
addUserAuthForBasic(user, create);
} catch (RuntimeException ex) {
return Response.status(CONFLICT)
@ -594,8 +594,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
createdUserRes = create(uriInfo, securityContext, user);
} catch (EntityNotFoundException ex) {
if (isSelfSignUpEnabled) {
if (securityContext.getUserPrincipal().getName().equals(create.getName())) {
// User is creating himself on signup ?! :(
if (securityContext.getUserPrincipal().getName().equals(user.getName())) {
User created = addHref(uriInfo, repository.create(uriInfo, user));
createdUserRes = Response.created(created.getHref()).entity(created).build();
} else {