|
@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -30,6 +31,7 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
private final PasswordEncoder passwordEncoder;
|
|
private final PasswordEncoder passwordEncoder;
|
|
|
private final AccountRepository accountRepository;
|
|
private final AccountRepository accountRepository;
|
|
|
private final PubkeyService pubkeyService;
|
|
private final PubkeyService pubkeyService;
|
|
|
|
|
+ private String avatarUrl;
|
|
|
|
|
|
|
|
public AccountRegistryServiceImpl(CodeService codeService, PasswordEncoder passwordEncoder,
|
|
public AccountRegistryServiceImpl(CodeService codeService, PasswordEncoder passwordEncoder,
|
|
|
AccountRepository accountRepository, PubkeyService pubkeyService) {
|
|
AccountRepository accountRepository, PubkeyService pubkeyService) {
|
|
@@ -39,6 +41,12 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
this.pubkeyService = pubkeyService;
|
|
this.pubkeyService = pubkeyService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @PostConstruct
|
|
|
|
|
+ public void setAvatarUrl() {
|
|
|
|
|
+ String domain = accountRepository.getUserRegistry().getDomain();
|
|
|
|
|
+ this.avatarUrl = String.format("//%s/dist/images/face.jpg", domain);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public synchronized Result createAccount(UserRegisterDto userRegisterDto) {
|
|
public synchronized Result createAccount(UserRegisterDto userRegisterDto) {
|
|
|
String captchaCode = userRegisterDto.getCaptchaCode();
|
|
String captchaCode = userRegisterDto.getCaptchaCode();
|
|
@@ -77,7 +85,7 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
long userId = getNextUserId();
|
|
long userId = getNextUserId();
|
|
|
String salt = RandomString.getSalt(64);
|
|
String salt = RandomString.getSalt(64);
|
|
|
String encodedPassword = passwordEncoder.encode(decryptCredential + salt);
|
|
String encodedPassword = passwordEncoder.encode(decryptCredential + salt);
|
|
|
- UserAccount userAccount = new UserAccount(userId, email, mobile, encodedPassword, salt);
|
|
|
|
|
|
|
+ UserAccount userAccount = new UserAccount(userId, email, mobile, encodedPassword, salt, avatarUrl);
|
|
|
accountRepository.saveAccount(userAccount);
|
|
accountRepository.saveAccount(userAccount);
|
|
|
return Result.result(ResultStatus.SUCCESS, "帐号已创建");
|
|
return Result.result(ResultStatus.SUCCESS, "帐号已创建");
|
|
|
}
|
|
}
|
|
@@ -105,7 +113,7 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
long userId = getNextUserId();
|
|
long userId = getNextUserId();
|
|
|
- UserAccount userAccount = new UserAccount(userId, email, mobile);
|
|
|
|
|
|
|
+ UserAccount userAccount = new UserAccount(userId, email, mobile, avatarUrl);
|
|
|
accountRepository.saveAccount(userAccount);
|
|
accountRepository.saveAccount(userAccount);
|
|
|
return accountRepository.getUserDetailByMobile(mobile);
|
|
return accountRepository.getUserDetailByMobile(mobile);
|
|
|
}
|
|
}
|