-
Couldn't load subscription status.
- Fork 180
Remove access tokens from entgo #1357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ce1250e to
267b66c
Compare
9d75dd9 to
af512a3
Compare
| @@ -0,0 +1,6 @@ | |||
| -- name: ValidateEnvBuilds :one | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're not using the results, we might be able to swap this for :exec and just check for an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't return an error
| func ValidateAccessToken(ctx context.Context, db *client.Client, accessToken string) bool { | ||
| hashedToken, err := keys.VerifyKey(keys.AccessTokenPrefix, accessToken) | ||
| if err != nil { | ||
| return false | ||
| } | ||
|
|
||
| exists, err := db.AccessToken.Query().Where(accesstoken.AccessTokenHash(hashedToken)).Exist(ctx) | ||
| _, err = db.GetUserIDFromAccessToken(ctx, hashedToken) | ||
| if err != nil { | ||
| log.Printf("Error while checking access token: %s\n", err.Error()) | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| return exists | ||
| return true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be easy to get some tests around this, via testcontainers
| if err != nil { | ||
| return false, err | ||
| } | ||
| if errors.Is(err, sql.ErrNoRows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a helper dberrors.IsNoRowsError
|
|
||
| e, err := db.Env.Query().Where( | ||
| env.ID(envID), | ||
| env.HasBuildsWith(envbuild.StatusEQ(envbuild.StatusWaiting)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the status code filter is missing now
No description provided.