fix: fix tokens to expire after 3 months and always inherit admin perms from user
This commit is contained in:
parent
e8f502073d
commit
b4c331daa0
3 changed files with 11 additions and 8 deletions
|
@ -61,7 +61,7 @@ func (db *DB) Tokens(ctx context.Context, userID xid.ID) (ts []Token, err error)
|
|||
}
|
||||
|
||||
// 3 months, might be customizable later
|
||||
const ExpiryTime = 3 * 30 * 24 * time.Hour
|
||||
const TokenExpiryTime = 3 * 30 * 24 * time.Hour
|
||||
|
||||
// SaveToken saves a token to the database.
|
||||
func (db *DB) SaveToken(ctx context.Context, userID xid.ID, tokenID xid.ID, apiOnly, readOnly bool) (t Token, err error) {
|
||||
|
@ -69,7 +69,7 @@ func (db *DB) SaveToken(ctx context.Context, userID xid.ID, tokenID xid.ID, apiO
|
|||
SetMap(map[string]any{
|
||||
"user_id": userID,
|
||||
"token_id": tokenID,
|
||||
"expires": time.Now().Add(ExpiryTime),
|
||||
"expires": time.Now().Add(TokenExpiryTime),
|
||||
"api_only": apiOnly,
|
||||
"read_only": readOnly,
|
||||
}).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue