|
|
@@ -14,12 +14,12 @@ import cn.reghao.tnb.account.app.model.po.UserAccount;
|
|
|
import cn.reghao.tnb.account.app.service.AccountRegistryService;
|
|
|
import cn.reghao.tnb.account.app.service.PubkeyService;
|
|
|
import cn.reghao.tnb.common.auth.AccountRole;
|
|
|
+import cn.reghao.tnb.common.util.ConstantId;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
@@ -29,7 +29,6 @@ import java.util.Set;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
- private final String zhihuAvatar = "//picx.zhimg.com/v2-abed1a8c04700ba7d72b45195223e0ff_xll.jpg";
|
|
|
private final CodeService codeService;
|
|
|
private final PasswordEncoder passwordEncoder;
|
|
|
private final AccountRepository accountRepository;
|
|
|
@@ -84,13 +83,13 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
String salt = RandomString.getSalt(64);
|
|
|
String encodedPassword = passwordEncoder.encode(decryptCredential + salt);
|
|
|
Set<UserAuthority> authorities = Set.of(new UserAuthority());
|
|
|
- if (userId == accountRepository.getStartUserId()) {
|
|
|
+ if (userId == ConstantId.START_USER_ID) {
|
|
|
authorities = Set.of(
|
|
|
new UserAuthority(AccountRole.admin.getValue()),
|
|
|
new UserAuthority(AccountRole.oss.getValue()));
|
|
|
}
|
|
|
|
|
|
- UserAccount userAccount = new UserAccount(userId, encodedPassword, salt, zhihuAvatar, authorities);
|
|
|
+ UserAccount userAccount = new UserAccount(userId, encodedPassword, salt, ConstantId.AVATAR_URL, authorities);
|
|
|
if (StringRegexp.matchEmail(principal)) {
|
|
|
userAccount.setEmail(principal);
|
|
|
} else if (StringRegexp.matchMobile(principal)) {
|
|
|
@@ -107,7 +106,7 @@ public class AccountRegistryServiceImpl implements AccountRegistryService {
|
|
|
@Override
|
|
|
public UserAccount createAccount(String principal, String password) {
|
|
|
long userId = accountRepository.getNextUserId();
|
|
|
- UserAccount userAccount = new UserAccount(userId, zhihuAvatar);
|
|
|
+ UserAccount userAccount = new UserAccount(userId, ConstantId.AVATAR_URL);
|
|
|
if (StringRegexp.matchEmail(principal)) {
|
|
|
userAccount.setEmail(principal);
|
|
|
accountRepository.saveAccount(userAccount);
|