feat: add existed phone number check when signup
Release package / release (push) Successful in 2m48s
Release package / release (push) Successful in 2m48s
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
"redhat.vscode-quarkus",
|
||||
"vscjava.vscode-java-pack",
|
||||
"redhat.vscode-xml",
|
||||
"esbenp.prettier-vscode"
|
||||
"esbenp.prettier-vscode",
|
||||
"PeterSchmalfeldt.explorer-exclude"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#Maven
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
release.properties
|
||||
.flattened-pom.xml
|
||||
|
||||
# Eclipse
|
||||
.project
|
||||
.classpath
|
||||
.settings/
|
||||
bin/
|
||||
|
||||
# IntelliJ
|
||||
.idea
|
||||
*.ipr
|
||||
*.iml
|
||||
*.iws
|
||||
|
||||
# NetBeans
|
||||
nb-configuration.xml
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode
|
||||
.factorypath
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Vim
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# patch
|
||||
*.orig
|
||||
*.rej
|
||||
|
||||
# Local environment
|
||||
.env
|
||||
|
||||
# Plugin directory
|
||||
/.quarkus/cli/plugins/
|
||||
# TLS Certificates
|
||||
.certs/
|
||||
@@ -33,6 +33,12 @@ public abstract class User extends PanacheEntity {
|
||||
|
||||
@Transactional
|
||||
public void signup(String name, String phone, String rawPassword) {
|
||||
// Check existed user
|
||||
Customer existedUser = User.find("phone", phone).firstResult();
|
||||
|
||||
if (existedUser != null) throw new BadRequestException("ExistedUser");
|
||||
|
||||
// Set user
|
||||
this.name = name;
|
||||
|
||||
if (!PhoneValidator.isValidInternationalPhone(phone)) {
|
||||
@@ -43,6 +49,7 @@ public abstract class User extends PanacheEntity {
|
||||
|
||||
this.hashedPassword = Password.hash(rawPassword).withArgon2().getResult();
|
||||
|
||||
// Save user
|
||||
this.persist();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user