|
|
@@ -5,11 +5,13 @@ import cn.reghao.jutil.jdk.security.RandomString;
|
|
|
import cn.reghao.tnb.auth.app.model.constant.VerifyChannel;
|
|
|
import cn.reghao.tnb.auth.app.db.mapper.UserAccountMapper;
|
|
|
import cn.reghao.tnb.auth.app.db.repository.AccountRepository;
|
|
|
+import cn.reghao.tnb.auth.app.model.dto.GrantRole;
|
|
|
import cn.reghao.tnb.auth.app.model.dto.PasswordResetDto;
|
|
|
import cn.reghao.tnb.auth.app.model.dto.PasswordUpdateDto;
|
|
|
import cn.reghao.tnb.auth.app.model.dto.UserEmailUpdate;
|
|
|
import cn.reghao.tnb.auth.app.model.po.UserAccount;
|
|
|
import cn.reghao.tnb.auth.app.security.form.AccountAuthToken;
|
|
|
+import cn.reghao.tnb.common.auth.AccountRole;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -37,6 +39,19 @@ public class AccountProfileService {
|
|
|
this.passwordEncoder = passwordEncoder;
|
|
|
}
|
|
|
|
|
|
+ public Result grantRole(GrantRole grantRole) {
|
|
|
+ String roleName = grantRole.getRole();
|
|
|
+ AccountRole accountRole = AccountRole.getByDesc(roleName);
|
|
|
+ if (accountRole == null) {
|
|
|
+ return Result.fail(String.format("role %s not exists", roleName));
|
|
|
+ }
|
|
|
+
|
|
|
+ AccountAuthToken authToken = accountTokenService.getAuthToken();
|
|
|
+ long userId = authToken.getUserId();
|
|
|
+ accountRepository.addUserRole(userId, roleName);
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
public Result updateUserScreenName(String screenName) {
|
|
|
AccountAuthToken authToken = accountTokenService.getAuthToken();
|
|
|
long userId = authToken.getUserId();
|