diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-28 03:15:08 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-28 03:15:08 +0900 |
| commit | 569eb3753db04c2ceca8d005b3e1cef15cfe8eb7 (patch) | |
| tree | 9cb80bf9642e1e7d6146551d81fd57988bb240df /backend | |
| parent | f106dfda762b499af52a741f682c34abb83d27d9 (diff) | |
| download | iosdc-japan-2024-albatross-569eb3753db04c2ceca8d005b3e1cef15cfe8eb7.tar.gz iosdc-japan-2024-albatross-569eb3753db04c2ceca8d005b3e1cef15cfe8eb7.tar.zst iosdc-japan-2024-albatross-569eb3753db04c2ceca8d005b3e1cef15cfe8eb7.zip | |
rename user's display_username to display_name
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/api/generated.go | 28 | ||||
| -rw-r--r-- | backend/api/handlers.go | 2 | ||||
| -rw-r--r-- | backend/auth/jwt.go | 20 | ||||
| -rw-r--r-- | backend/db/models.go | 12 | ||||
| -rw-r--r-- | backend/db/query.sql.go | 28 | ||||
| -rw-r--r-- | backend/schema.sql | 2 |
6 files changed, 46 insertions, 46 deletions
diff --git a/backend/api/generated.go b/backend/api/generated.go index 23811ca..1abdf73 100644 --- a/backend/api/generated.go +++ b/backend/api/generated.go @@ -22,11 +22,11 @@ import ( // JwtPayload defines model for JwtPayload. type JwtPayload struct { - DisplayUsername string `json:"display_username"` - IconPath *string `json:"icon_path"` - IsAdmin bool `json:"is_admin"` - UserId float32 `json:"user_id"` - Username string `json:"username"` + DisplayName string `json:"display_name"` + IconPath *string `json:"icon_path"` + IsAdmin bool `json:"is_admin"` + UserId float32 `json:"user_id"` + Username string `json:"username"` } // PostApiLoginJSONBody defines parameters for PostApiLogin. @@ -172,15 +172,15 @@ func (sh *strictHandler) PostApiLogin(ctx echo.Context) error { // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/6RSwY7aQAz9lcjnKAToKTeqXlj1gFT1VFXISQwM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2Eg7EQxk6Z001FC6OKnxJzm1UHKqexM/Nn26XT8/3kvLgGv66PbW+7/alKoZs", + "uFAnrOPcT3n+gOogv2geTniLn+zq+0MpI8n94WvSyhsXxgR8a6uKVHettV2CbTgQhzgq1dHNT/nyASkN", + "qeL+n1Ws+RWtqZPKUx17odUP5ZyJ/kfQmf+8zUR8Mq0zwrVtGvQdFPBdySdjsvu+7/8EAAD//3hNTqrS", + "BAAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/backend/api/handlers.go b/backend/api/handlers.go index b8f80f3..c435d72 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -55,7 +55,7 @@ func _assertJwtPayloadIsCompatibleWithJWTClaims() { var p JwtPayload p.UserId = float32(c.UserID) p.Username = c.Username - p.DisplayUsername = c.DisplayUsername + p.DisplayName = c.DisplayName p.IconPath = c.IconPath p.IsAdmin = c.IsAdmin _ = p diff --git a/backend/auth/jwt.go b/backend/auth/jwt.go index aa35de6..1b153fe 100644 --- a/backend/auth/jwt.go +++ b/backend/auth/jwt.go @@ -11,11 +11,11 @@ import ( ) type JWTClaims struct { - UserID int `json:"user_id"` - Username string `json:"username"` - DisplayUsername string `json:"display_username"` - IconPath *string `json:"icon_path"` - IsAdmin bool `json:"is_admin"` + UserID int `json:"user_id"` + Username string `json:"username"` + DisplayName string `json:"display_name"` + IconPath *string `json:"icon_path"` + IsAdmin bool `json:"is_admin"` jwt.RegisteredClaims } @@ -25,11 +25,11 @@ func NewJWT(user *db.User) (string, error) { iconPath = &user.IconPath.String } claims := &JWTClaims{ - UserID: int(user.UserID), - Username: user.Username, - DisplayUsername: user.DisplayUsername, - IconPath: iconPath, - IsAdmin: user.IsAdmin, + UserID: int(user.UserID), + Username: user.Username, + DisplayName: user.DisplayName, + IconPath: iconPath, + IsAdmin: user.IsAdmin, RegisteredClaims: jwt.RegisteredClaims{ ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour * 24)), }, diff --git a/backend/db/models.go b/backend/db/models.go index 4eda2cc..a54fd8c 100644 --- a/backend/db/models.go +++ b/backend/db/models.go @@ -16,12 +16,12 @@ type Game struct { } type User struct { - UserID int32 - Username string - DisplayUsername string - IconPath pgtype.Text - IsAdmin bool - CreatedAt pgtype.Timestamp + UserID int32 + Username string + DisplayName string + IconPath pgtype.Text + IsAdmin bool + CreatedAt pgtype.Timestamp } type UserAuth struct { diff --git a/backend/db/query.sql.go b/backend/db/query.sql.go index 72c6502..12651d2 100644 --- a/backend/db/query.sql.go +++ b/backend/db/query.sql.go @@ -12,23 +12,23 @@ import ( ) const getUserAuthByUsername = `-- name: GetUserAuthByUsername :one -SELECT users.user_id, username, display_username, icon_path, is_admin, created_at, user_auth_id, user_auths.user_id, auth_type, password_hash FROM users +SELECT users.user_id, username, display_name, icon_path, is_admin, created_at, user_auth_id, user_auths.user_id, auth_type, password_hash FROM users JOIN user_auths ON users.user_id = user_auths.user_id WHERE users.username = $1 LIMIT 1 ` type GetUserAuthByUsernameRow struct { - UserID int32 - Username string - DisplayUsername string - IconPath pgtype.Text - IsAdmin bool - CreatedAt pgtype.Timestamp - UserAuthID int32 - UserID_2 int32 - AuthType string - PasswordHash pgtype.Text + UserID int32 + Username string + DisplayName string + IconPath pgtype.Text + IsAdmin bool + CreatedAt pgtype.Timestamp + UserAuthID int32 + UserID_2 int32 + AuthType string + PasswordHash pgtype.Text } func (q *Queries) GetUserAuthByUsername(ctx context.Context, username string) (GetUserAuthByUsernameRow, error) { @@ -37,7 +37,7 @@ func (q *Queries) GetUserAuthByUsername(ctx context.Context, username string) (G err := row.Scan( &i.UserID, &i.Username, - &i.DisplayUsername, + &i.DisplayName, &i.IconPath, &i.IsAdmin, &i.CreatedAt, @@ -50,7 +50,7 @@ func (q *Queries) GetUserAuthByUsername(ctx context.Context, username string) (G } const getUserById = `-- name: GetUserById :one -SELECT user_id, username, display_username, icon_path, is_admin, created_at FROM users +SELECT user_id, username, display_name, icon_path, is_admin, created_at FROM users WHERE users.user_id = $1 LIMIT 1 ` @@ -61,7 +61,7 @@ func (q *Queries) GetUserById(ctx context.Context, userID int32) (User, error) { err := row.Scan( &i.UserID, &i.Username, - &i.DisplayUsername, + &i.DisplayName, &i.IconPath, &i.IsAdmin, &i.CreatedAt, diff --git a/backend/schema.sql b/backend/schema.sql index 999d628..5a70eeb 100644 --- a/backend/schema.sql +++ b/backend/schema.sql @@ -1,7 +1,7 @@ CREATE TABLE users ( user_id SERIAL PRIMARY KEY, username VARCHAR(64) NOT NULL UNIQUE, - display_username VARCHAR(64) NOT NULL, + display_name VARCHAR(64) NOT NULL, icon_path VARCHAR(255), is_admin BOOLEAN NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW() |
