split oauth_tokens.claims column up; improved fonts; allow multiple sse connections per user; make navbar and use friendly
This commit is contained in:
@@ -3,7 +3,6 @@ package authentication
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"ruben/inventory2/internal/consts"
|
||||
@@ -102,7 +101,14 @@ func (a *Authenticator) GetAccessTokenClaimsAndExpiration(ctx context.Context, a
|
||||
`
|
||||
SELECT
|
||||
expiry,
|
||||
claims
|
||||
|
||||
id_token_custom_claims_name,
|
||||
id_token_custom_claims_picture,
|
||||
id_token_custom_claims_nickname,
|
||||
id_token_custom_claims_given_name,
|
||||
id_token_custom_claims_family_name,
|
||||
id_token_custom_claims_updated_at
|
||||
|
||||
FROM
|
||||
oauth_tokens
|
||||
WHERE
|
||||
@@ -117,8 +123,13 @@ func (a *Authenticator) GetAccessTokenClaimsAndExpiration(ctx context.Context, a
|
||||
}
|
||||
|
||||
type Row struct {
|
||||
Expiry time.Time
|
||||
Claims json.RawMessage
|
||||
Expiry time.Time
|
||||
Id_token_custom_claims_name string
|
||||
Id_token_custom_claims_picture string
|
||||
Id_token_custom_claims_nickname string
|
||||
Id_token_custom_claims_given_name string
|
||||
Id_token_custom_claims_family_name string
|
||||
Id_token_custom_claims_updated_at time.Time
|
||||
}
|
||||
|
||||
r, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByNameLax[Row])
|
||||
@@ -129,9 +140,12 @@ func (a *Authenticator) GetAccessTokenClaimsAndExpiration(ctx context.Context, a
|
||||
return AccessTokenClaims{}, time.Time{}, fmt.Errorf("failed to scan row: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(r.Claims, &claims); err != nil {
|
||||
return AccessTokenClaims{}, time.Time{}, fmt.Errorf("failed to scan claims json: %w", err)
|
||||
}
|
||||
claims.Name = r.Id_token_custom_claims_name
|
||||
claims.Picture = r.Id_token_custom_claims_picture
|
||||
claims.Nickname = r.Id_token_custom_claims_nickname
|
||||
claims.GivenName = r.Id_token_custom_claims_given_name
|
||||
claims.FamilyName = r.Id_token_custom_claims_family_name
|
||||
claims.UpdatedAt = r.Id_token_custom_claims_updated_at
|
||||
|
||||
return claims, r.Expiry, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user