|
@@ -22,7 +22,9 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -105,7 +107,7 @@ public class UserController extends CommonController {
|
|
|
public CommonResult<UserInfo> wxMpLogin(LoginParam loginParam){
|
|
|
UserInfo userInfo = userService.wxMpLogin(loginParam);
|
|
|
if(loginParam.getOpenId() != null){
|
|
|
- UserAuthInfo userAuthInfo = sysUserService.getUserAuthInfo(loginParam.getOpenId());
|
|
|
+ UserAuthInfo userAuthInfo = sysUserService.getUserAuthInfo(userInfo.getOpenId());
|
|
|
if(userAuthInfo == null){
|
|
|
//如果没有注册,需要注册该微信用户
|
|
|
UserForm userForm = new UserForm();
|
|
@@ -120,13 +122,19 @@ public class UserController extends CommonController {
|
|
|
//生成token
|
|
|
userAuthInfo = new UserAuthInfo();
|
|
|
userAuthInfo.setUsername(userInfo.getOpenId());
|
|
|
+ Set<String> roles = new HashSet<>();
|
|
|
+ roles.add("PARK_USER");
|
|
|
userInfo.setAccessToken(getToken(userAuthInfo));
|
|
|
}else{
|
|
|
userInfo.setId(userAuthInfo.getUserId().toString());
|
|
|
userInfo.setNickName(userAuthInfo.getNickname());
|
|
|
userInfo.setAvatarUrl(userInfo.getAvatarUrl());
|
|
|
+ Set<String> roles = new HashSet<>();
|
|
|
+ roles.add("PARK_USER");
|
|
|
+ userAuthInfo.setRoles(roles);
|
|
|
//生成token
|
|
|
- userInfo.setAccessToken(getToken(userAuthInfo));
|
|
|
+ String token = getToken(userAuthInfo);
|
|
|
+ userInfo.setAccessToken(token);
|
|
|
}
|
|
|
|
|
|
}
|