login demo
This commit is contained in:
parent
53979cc3b7
commit
b70d79bd90
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue