Add oauth token failure model and notification
This will allow me to mark when an oauth token fails and surface it to the user so that they can re-up on their auth token.
This commit is contained in:
parent
0a74bd8345
commit
a2e67e3d60
28 changed files with 2375 additions and 246 deletions
|
|
@ -21,7 +21,7 @@ import (
|
|||
//go:embed oauth_by_user_id.bob.sql
|
||||
var formattedQueries_oauth_by_user_id string
|
||||
|
||||
var oauthTokenByUserIdSQL = formattedQueries_oauth_by_user_id[156:642]
|
||||
var oauthTokenByUserIdSQL = formattedQueries_oauth_by_user_id[156:694]
|
||||
|
||||
type OauthTokenByUserIdQuery = orm.ModQuery[*dialect.SelectQuery, oauthTokenByUserId, OauthTokenByUserIdRow, []OauthTokenByUserIdRow, oauthTokenByUserIdTransformer]
|
||||
|
||||
|
|
@ -51,6 +51,7 @@ func OauthTokenByUserId(UserID int32) *OauthTokenByUserIdQuery {
|
|||
row.ScheduleScanByIndex(6, &t.ArcgisID)
|
||||
row.ScheduleScanByIndex(7, &t.ArcgisLicenseTypeID)
|
||||
row.ScheduleScanByIndex(8, &t.RefreshTokenExpires)
|
||||
row.ScheduleScanByIndex(9, &t.InvalidatedAt)
|
||||
return &t, nil
|
||||
}, func(v any) (OauthTokenByUserIdRow, error) {
|
||||
return *(v.(*OauthTokenByUserIdRow)), nil
|
||||
|
|
@ -58,23 +59,24 @@ func OauthTokenByUserId(UserID int32) *OauthTokenByUserIdQuery {
|
|||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(7, 449))
|
||||
q.SetTable(expressionTypArgs.subExpr(455, 466))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(474, 486))
|
||||
q.AppendSelect(expressionTypArgs.subExpr(7, 501))
|
||||
q.SetTable(expressionTypArgs.subExpr(507, 518))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(526, 538))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type OauthTokenByUserIdRow = struct {
|
||||
ID int32 `db:"id"`
|
||||
AccessToken string `db:"access_token"`
|
||||
AccessTokenExpires time.Time `db:"access_token_expires"`
|
||||
RefreshToken string `db:"refresh_token"`
|
||||
Username string `db:"username"`
|
||||
UserID int32 `db:"user_id"`
|
||||
ArcgisID null.Val[string] `db:"arcgis_id"`
|
||||
ArcgisLicenseTypeID null.Val[string] `db:"arcgis_license_type_id"`
|
||||
RefreshTokenExpires time.Time `db:"refresh_token_expires"`
|
||||
ID int32 `db:"id"`
|
||||
AccessToken string `db:"access_token"`
|
||||
AccessTokenExpires time.Time `db:"access_token_expires"`
|
||||
RefreshToken string `db:"refresh_token"`
|
||||
Username string `db:"username"`
|
||||
UserID int32 `db:"user_id"`
|
||||
ArcgisID null.Val[string] `db:"arcgis_id"`
|
||||
ArcgisLicenseTypeID null.Val[string] `db:"arcgis_license_type_id"`
|
||||
RefreshTokenExpires time.Time `db:"refresh_token_expires"`
|
||||
InvalidatedAt null.Val[time.Time] `db:"invalidated_at"`
|
||||
}
|
||||
|
||||
type oauthTokenByUserIdTransformer = bob.SliceTransformer[OauthTokenByUserIdRow, []OauthTokenByUserIdRow]
|
||||
|
|
@ -87,8 +89,8 @@ func (o oauthTokenByUserId) args() iter.Seq[orm.ArgWithPosition] {
|
|||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "userID",
|
||||
Start: 484,
|
||||
Stop: 486,
|
||||
Start: 536,
|
||||
Stop: 538,
|
||||
Expression: o.UserID,
|
||||
}) {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
-- This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
-- OauthTokenByUserId
|
||||
SELECT "oauth_token"."id" AS "id", "oauth_token"."access_token" AS "access_token", "oauth_token"."access_token_expires" AS "access_token_expires", "oauth_token"."refresh_token" AS "refresh_token", "oauth_token"."username" AS "username", "oauth_token"."user_id" AS "user_id", "oauth_token"."arcgis_id" AS "arcgis_id", "oauth_token"."arcgis_license_type_id" AS "arcgis_license_type_id", "oauth_token"."refresh_token_expires" AS "refresh_token_expires" FROM oauth_token WHERE
|
||||
SELECT "oauth_token"."id" AS "id", "oauth_token"."access_token" AS "access_token", "oauth_token"."access_token_expires" AS "access_token_expires", "oauth_token"."refresh_token" AS "refresh_token", "oauth_token"."username" AS "username", "oauth_token"."user_id" AS "user_id", "oauth_token"."arcgis_id" AS "arcgis_id", "oauth_token"."arcgis_license_type_id" AS "arcgis_license_type_id", "oauth_token"."refresh_token_expires" AS "refresh_token_expires", "oauth_token"."invalidated_at" AS "invalidated_at" FROM oauth_token WHERE
|
||||
user_id = $1;
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ func TestOauthTokenByUserId(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(columns) != 9 {
|
||||
t.Fatalf("expected %d columns, got %d", 9, len(columns))
|
||||
if len(columns) != 10 {
|
||||
t.Fatalf("expected %d columns, got %d", 10, len(columns))
|
||||
}
|
||||
|
||||
if columns[0] != "id" {
|
||||
|
|
@ -123,5 +123,9 @@ func TestOauthTokenByUserId(t *testing.T) {
|
|||
if columns[8] != "refresh_token_expires" {
|
||||
t.Fatalf("expected column %d to be %s, got %s", 8, "refresh_token_expires", columns[8])
|
||||
}
|
||||
|
||||
if columns[9] != "invalidated_at" {
|
||||
t.Fatalf("expected column %d to be %s, got %s", 9, "invalidated_at", columns[9])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue