chore: remove access token after sign out

This commit is contained in:
Steven
2024-05-20 08:53:29 +08:00
parent 21838d0aae
commit fb15386db2
2 changed files with 16 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package v1
import (
"context"
"fmt"
"log/slog"
"regexp"
"strings"
"time"
@@ -214,6 +215,17 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest)
}
func (s *APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*emptypb.Empty, error) {
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", err)
}
}
if err := s.clearAccessTokenCookie(ctx); err != nil {
return nil, status.Errorf(codes.Internal, "failed to set grpc header, error: %v", err)
}