diff --git a/backend/src/main/java/io/metersphere/controller/LoginController.java b/backend/src/main/java/io/metersphere/controller/LoginController.java index 4cb84d1e4e..5099706ff5 100644 --- a/backend/src/main/java/io/metersphere/controller/LoginController.java +++ b/backend/src/main/java/io/metersphere/controller/LoginController.java @@ -35,7 +35,8 @@ public class LoginController { try { subject.login(token); if (subject.isAuthenticated()) { - return ResultHolder.success(""); + // 返回 userDTO + return ResultHolder.success(subject.getSession().getAttribute("user")); } else { return ResultHolder.error("login fail"); } diff --git a/backend/src/main/java/io/metersphere/user/SessionUser.java b/backend/src/main/java/io/metersphere/user/SessionUser.java index 0a36e97649..187a39621f 100644 --- a/backend/src/main/java/io/metersphere/user/SessionUser.java +++ b/backend/src/main/java/io/metersphere/user/SessionUser.java @@ -1,26 +1,18 @@ package io.metersphere.user; +import io.metersphere.dto.UserDTO; +import org.springframework.beans.BeanUtils; + import java.io.Serializable; -public class SessionUser implements Serializable { +public class SessionUser extends UserDTO implements Serializable { private static final long serialVersionUID = -7149638440406959033L; - private String id; - private String name; - public String getId() { - return id; + public static SessionUser fromUser(UserDTO user) { + SessionUser sessionUser = new SessionUser(); + BeanUtils.copyProperties(user, sessionUser); + return sessionUser; } - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } }