public string GetJwtKey() { JwtDao jwtdao = new JwtDao(_configuracoes); Jwt jwt = jwtdao.GetById(1); if (jwt.id != 0) { jwt.token = BCrypt.Net.BCrypt.HashPassword(DateTime.Now.ToString("yyyyMMddHHmmss")); jwtdao.Insert(jwt); } return(jwt.token); }
public void SetUserToken(User user, int expires) { JwtDao jwtdao = new JwtDao(_configuracoes); var tok = new JwtTokenBuilder() .AddSecurityKey(JwtSecurityKey.Create(jwtdao.GetJwtKey())) .AddExpiry(expires) .AddClaim("uid", user.id.ToString()) .Build(); token.user_id = user.id; token.token = tok; Insert(token); }