Skip to content

Commit 1770837

Browse files
committed
AYS-410 | Value of Temp Value Has Been Changed with Random Text in User Create Flow
1 parent 79f5371 commit 1770837

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/main/java/org/ays/auth/service/impl/AysUserCreateServiceImpl.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
import org.ays.auth.util.exception.AysUserAlreadyExistsByEmailAddressException;
1616
import org.ays.auth.util.exception.AysUserAlreadyExistsByPhoneNumberException;
1717
import org.ays.common.model.AysPhoneNumber;
18+
import org.ays.common.util.AysRandomUtil;
1819
import org.ays.institution.model.Institution;
1920
import org.springframework.stereotype.Service;
2021
import org.springframework.transaction.annotation.Transactional;
2122

2223
import java.util.List;
2324
import java.util.Set;
24-
import java.util.UUID;
2525

2626
/**
2727
* Service implementation for creating new users in the system.
@@ -58,9 +58,9 @@ class AysUserCreateServiceImpl implements AysUserCreateService {
5858
* </p>
5959
*
6060
* @param createRequest The request object containing data for the new user.
61-
* @throws AysUserAlreadyExistsByEmailAddressException if the email address is already associated with another user.
62-
* @throws AysUserAlreadyExistsByPhoneNumberException if the phone number is already associated with another user.
63-
* @throws AysRolesNotExistException if any of the provided role IDs do not exist.
61+
* @throws AysUserAlreadyExistsByEmailAddressException if the email address is already associated with another user.
62+
* @throws AysUserAlreadyExistsByPhoneNumberException if the phone number is already associated with another user.
63+
* @throws AysRolesNotExistException if any of the provided role IDs do not exist.
6464
*/
6565
@Override
6666
public void create(final AysUserCreateRequest createRequest) {
@@ -78,10 +78,18 @@ public void create(final AysUserCreateRequest createRequest) {
7878
this.validateRolesAndSet(user, createRequest.getRoleIds());
7979

8080
user.activate();
81-
user.setInstitution(Institution.builder().id(identity.getInstitutionId()).build());
82-
user.setPassword(AysUser.Password.builder().value(UUID.randomUUID().toString()).build());
83-
84-
AysUser savedUser = userSavePort.save(user);
81+
user.setInstitution(
82+
Institution.builder()
83+
.id(identity.getInstitutionId())
84+
.build()
85+
);
86+
user.setPassword(
87+
AysUser.Password.builder()
88+
.value(AysRandomUtil.generateText(15))
89+
.build()
90+
);
91+
92+
final AysUser savedUser = userSavePort.save(user);
8593

8694
userMailService.sendPasswordCreateEmail(savedUser);
8795
}

0 commit comments

Comments
 (0)