Skip to content

Commit

Permalink
Token lifetime (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
swuecho authored May 30, 2023
1 parent 4d24045 commit c74f546
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/chat_auth_user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (h *AuthUserHandler) Login(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &cookie)

w.Header().Set("Content-Type", "application/json")
expiresIn := time.Now().Add(time.Hour * 8).Unix()
expiresIn := time.Now().Add(lifetime).Unix()
json.NewEncoder(w).Encode(TokenResult{AccessToken: token, ExpiresIn: int(expiresIn)})
w.WriteHeader(http.StatusOK)

Expand Down
2 changes: 2 additions & 0 deletions api/sqlc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ CREATE TABLE IF NOT EXISTS jwt_secrets (

ALTER TABLE jwt_secrets ADD COLUMN IF NOT EXISTS lifetime smallint NOT NULL default 24;

UPDATE jwt_secrets SET lifetime = 240;

CREATE TABLE IF NOT EXISTS chat_model (
id SERIAL PRIMARY KEY,
-- model name 'claude-v1', 'gpt-3.5-turbo'
Expand Down

0 comments on commit c74f546

Please sign in to comment.