Skip to content

Commit

Permalink
fix: delete access token when sign out
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Jul 13, 2024
1 parent f374169 commit 6825c1d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server/router/api/v1/auth_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,14 @@ func (s *APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*em
accessToken, ok := ctx.Value(accessTokenContextKey).(string)
// Try to delete the access token from the store.
if ok {
_, err := s.DeleteUserAccessToken(ctx, &v1pb.DeleteUserAccessTokenRequest{
AccessToken: accessToken,
})
if err != nil {
slog.Error("failed to delete access token", slog.Any("err", err))
user, _ := s.GetCurrentUser(ctx)
if user != nil {
if _, err := s.DeleteUserAccessToken(ctx, &v1pb.DeleteUserAccessTokenRequest{
Name: fmt.Sprintf("%s%d", UserNamePrefix, user.ID),
AccessToken: accessToken,
}); err != nil {
slog.Error("failed to delete access token", slog.Any("err", err))
}
}
}

Expand Down

0 comments on commit 6825c1d

Please sign in to comment.