feat: NAS登录
This commit is contained in:
parent
aae8851a86
commit
cc3f07fbf1
@ -21,6 +21,7 @@ import net.sf.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@ -110,14 +111,15 @@ public class SysLoginController {
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||
try {
|
||||
// get请求获取群晖token
|
||||
// 使用UriComponentsBuilder构建带有查询参数的URL
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(DSM_LOGIN_URL)
|
||||
.queryParam("api", "SYNO.API.Auth")
|
||||
.queryParam("version", "3")
|
||||
.queryParam("version", "6")
|
||||
.queryParam("method", "login")
|
||||
.queryParam("account", "peihaoyu")
|
||||
.queryParam("passwd", "Phy0316.")
|
||||
.queryParam("account", user.getSynoUserName())
|
||||
.queryParam("passwd", user.getSynoPassword())
|
||||
.queryParam("enable_syno_token", "yes");
|
||||
// 构建完整的URL
|
||||
String url = builder.toUriString();
|
||||
@ -129,6 +131,9 @@ public class SysLoginController {
|
||||
if (jsonObject.get("success").equals(true)) {
|
||||
user.setSynoToken(jsonObject.getJSONObject("data").getString("synotoken"));
|
||||
}
|
||||
} catch (RestClientException e) {
|
||||
logger.error("请求群晖token失败,异常信息", e);
|
||||
}
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
|
@ -149,6 +149,14 @@ public class SysUser extends BaseEntity {
|
||||
@Getter
|
||||
private IpLocation location;
|
||||
|
||||
// 群晖用户名
|
||||
private String synoUserName;
|
||||
|
||||
|
||||
// 群晖密码
|
||||
private String synoPassword;
|
||||
|
||||
// 群晖token
|
||||
private String synoToken;
|
||||
|
||||
public SysUser() {
|
||||
@ -347,6 +355,26 @@ public class SysUser extends BaseEntity {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public IpLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getSynoUserName() {
|
||||
return synoUserName;
|
||||
}
|
||||
|
||||
public void setSynoUserName(String synoUserName) {
|
||||
this.synoUserName = synoUserName;
|
||||
}
|
||||
|
||||
public String getSynoPassword() {
|
||||
return synoPassword;
|
||||
}
|
||||
|
||||
public void setSynoPassword(String synoPassword) {
|
||||
this.synoPassword = synoPassword;
|
||||
}
|
||||
|
||||
public String getSynoToken() {
|
||||
return synoToken;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user