-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from KonferCA/feat/64/user-role-enum
Feat/64/user role enum
- Loading branch information
Showing
13 changed files
with
196 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
BEGIN; | ||
|
||
CREATE TYPE user_role AS ENUM ('admin', 'startup_owner', 'investor'); | ||
|
||
COMMIT; | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
BEGIN; | ||
|
||
DROP TYPE user_role; | ||
|
||
COMMIT; | ||
-- +goose StatementEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
BEGIN; | ||
|
||
ALTER TABLE users ADD COLUMN role_enum user_role NOT NULL; | ||
|
||
UPDATE users | ||
SET role_enum = role::user_role; | ||
|
||
ALTER TABLE users DROP COLUMN role; | ||
ALTER TABLE users RENAME COLUMN role_enum TO role; | ||
|
||
COMMIT; | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
BEGIN; | ||
|
||
ALTER TABLE users ADD COLUMN role_varchar VARCHAR(50) NOT NULL; | ||
|
||
UPDATE users | ||
SET role_varchar = role::text; | ||
|
||
ALTER TABLE users DROP COLUMN role; | ||
ALTER TABLE users RENAME COLUMN role_varchar TO role; | ||
|
||
COMMIT; | ||
-- +goose StatementEnd |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
package jwt | ||
|
||
import golangJWT "github.com/golang-jwt/jwt/v5" | ||
import ( | ||
"github.com/KonferCA/NoKap/db" | ||
golangJWT "github.com/golang-jwt/jwt/v5" | ||
) | ||
|
||
type JWTClaims struct { | ||
UserID string `json:"user_id"` | ||
Role string `json:"role"` | ||
TokenType string `json:"token_type"` | ||
UserID string `json:"user_id"` | ||
Role db.UserRole `json:"role"` | ||
TokenType string `json:"token_type"` | ||
golangJWT.RegisteredClaims | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.