在春季在JWT中发送自定义用户ID

时间:2018-07-27 07:50:18

标签: spring-boot spring-security jwt angular5

我正在从事Spring Boot 2.0.1 / Angular 5项目,在这里我必须实现JWT登录功能。我的自定义用户由实体NotifiedUser描述如下:

k6 convert exported.har

我想在JWT中的类JWTAuthenticationFilter中发送notifydUserId:

package com.sap.lsm.entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.sap.lsm.enumerations.LSMUserStatus;
import com.sap.lsm.enumerations.NotifiedUserType;

@Entity
@Table(name = "f_LSM_User")
public class NotifiedUser implements Serializable {

public List<LSM_Role> getLsmRoles() {
    return lsmRoles;
}

public void setLsmRoles(List<LSM_Role> lsmRoles) {
    this.lsmRoles = lsmRoles;
}

private static final long serialVersionUID = 1L;

@Id
@Column(name = "NOTIFIED_USER_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long notifiedUserId;

@Column(name = "USERNAME", nullable = false, length=255)
private String username;

@Column(name = "PASSWORD", nullable = false)
private String password;

@Column(name = "UserEMAIL", nullable = false)
private String UserEmail;

@Enumerated(EnumType.STRING)
private LSMUserStatus UserStatus;

@Enumerated(EnumType.STRING)
private NotifiedUserType role;

@ManyToMany(mappedBy = "lsmUsers")
private List<LSM_Role> lsmRoles;

public NotifiedUser() {

}

public NotifiedUser(Long notifiedUserId, String username, String password, String userEmail,
        NotifiedUserType role, LSMUserStatus UserStatus) {
    super();
    this.notifiedUserId = notifiedUserId;
    this.username = username;
    this.password = password;
    UserEmail = userEmail;
    this.role = role;
    this.UserStatus = UserStatus;
}

public Long getNotifiedUserId() {
    return notifiedUserId;
}

public void setNotifiedUserId(Long notifiedUserId) {
    this.notifiedUserId = notifiedUserId;
}

public String getUsername() {
    return username;
}

public void setUsername(String username) {
    this.username = username;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

public String getUserEmail() {
    return UserEmail;
}

public void setUserEmail(String userEmail) {
    UserEmail = userEmail;
}

public NotifiedUserType getRole() {
    return role;
}

public void setRole(NotifiedUserType role) {
    this.role = role;
}

public LSMUserStatus getUserStatus() {
    return UserStatus;
}

public void setUserStatus(LSMUserStatus userStatus) {
    UserStatus = userStatus;
}

}

目的是稍后在angular上获取用户ID。

请帮助我, 谢谢

0 个答案:

没有答案