From 1acf9a48021d0af1d81fdf3ed8fcf8dffd020f6b Mon Sep 17 00:00:00 2001 From: hongjli <3117313295@qq.com> Date: 星期二, 15 四月 2025 14:20:51 +0800 Subject: [PATCH] 登录,注册,获取用户信息---接口 --- src/main/java/com/weiwojc/security/JwtUserDetails.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/weiwojc/security/JwtUserDetails.java b/src/main/java/com/weiwojc/security/JwtUserDetails.java new file mode 100644 index 0000000..3514ba6 --- /dev/null +++ b/src/main/java/com/weiwojc/security/JwtUserDetails.java @@ -0,0 +1,54 @@ +package com.weiwojc.security; + +import lombok.Getter; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.Collections; + +@Getter +public class JwtUserDetails implements UserDetails { + private final Long userId; + private final String username; + + public JwtUserDetails(Long userId, String username) { + this.userId = userId; + this.username = username; + } + + @Override + public Collection<? extends GrantedAuthority> getAuthorities() { + return Collections.emptyList(); + } + + @Override + public String getPassword() { + return null; + } + + @Override + public String getUsername() { + return username; + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } +} \ No newline at end of file -- Gitblit v1.9.3