4
hao
2025-04-16 c5fb1fbcbb2bf4d511773d348f9ef625855c61fc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.app.config.service;
 
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.system.user.entity.SysUser;
 
import org.springframework.stereotype.Service;
 
 
/**
 * @author jinbin
 * @date 2018-07-08 21:04
 */
@Service("TokenService")
public class TokenService {
    public String getToken(SysUser user) {
        String token="";
        token= JWT.create().withAudience(user.getFcode())// 将 user id 保存到 token 里面
                .sign(Algorithm.HMAC256(user.getFpassword()));// 以 password 作为 token 的密钥
        return token;
    }
//    public String getToken(SysUser user) {
//        String token="";
//        token= JWT.create().withAudience(user.getUserCode())// 将 user id 保存到 token 里面
//                .sign(Algorithm.HMAC256(user.getUserPassword()));// 以 password 作为 token 的密钥
//        return token;
//    }
}