MCPcopy Index your code
hub / github.com/rilldata/rill / InsertUserAuthToken

Method InsertUserAuthToken

admin/database/postgres/postgres.go:1210–1225  ·  view source on GitHub ↗
(ctx context.Context, opts *database.InsertUserAuthTokenOptions)

Source from the content-addressed store, hash-verified

1208}
1209
1210func (c *connection) InsertUserAuthToken(ctx context.Context, opts *database.InsertUserAuthTokenOptions) (*database.UserAuthToken, error) {
1211 if err := database.Validate(opts); err != nil {
1212 return nil, err
1213 }
1214
1215 res := &database.UserAuthToken{}
1216 err := c.getDB(ctx).QueryRowxContext(ctx, `
1217 INSERT INTO user_auth_tokens (id, secret_hash, user_id, display_name, auth_client_id, representing_user_id, refresh, expires_on)
1218 VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *`,
1219 opts.ID, opts.SecretHash, opts.UserID, opts.DisplayName, opts.AuthClientID, opts.RepresentingUserID, opts.Refresh, opts.ExpiresOn,
1220 ).StructScan(res)
1221 if err != nil {
1222 return nil, parseErr("auth token", err)
1223 }
1224 return res, nil
1225}
1226
1227func (c *connection) UpdateUserAuthTokenUsedOn(ctx context.Context, ids []string) error {
1228 _, err := c.getDB(ctx).ExecContext(ctx, "UPDATE user_auth_tokens SET used_on=now() WHERE id=ANY($1)", ids)

Callers

nothing calls this directly

Calls 3

getDBMethod · 0.95
ValidateFunction · 0.92
parseErrFunction · 0.85

Tested by

no test coverage detected