(userID, role string, expSec int64, sessionID string)
| 766 | } |
| 767 | |
| 768 | func (h *AuthHandler) createToken(userID, role string, expSec int64, sessionID string) (string, error) { |
| 769 | claims := jwt.MapClaims{ |
| 770 | "sub": userID, |
| 771 | "role": role, |
| 772 | "exp": time.Now().Add(time.Duration(expSec) * time.Second).Unix(), |
| 773 | "iat": time.Now().Unix(), |
| 774 | } |
| 775 | if sessionID != "" { |
| 776 | claims["sessionId"] = sessionID |
| 777 | } |
| 778 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) |
| 779 | return token.SignedString([]byte(h.cfg.JWTSecret)) |
| 780 | } |
| 781 | |
| 782 | // Profile handles GET /auth/profile. |
| 783 | func (h *AuthHandler) Profile(w http.ResponseWriter, r *http.Request) { |
no outgoing calls
no test coverage detected