Skip to content

Commit

Permalink
Fix logout with NordAccount token not working
Browse files Browse the repository at this point in the history
Signed-off-by: Emilijus Stankus <[email protected]>
  • Loading branch information
Emilijus Stankus authored and piotrjurkiewicz committed Oct 27, 2023
1 parent 16775ac commit eee8297
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions daemon/rpc_logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.Payload, er
if !in.GetPersistToken() {
if err := r.api.DeleteToken(tokenData.Token); err != nil {
log.Println(internal.ErrorPrefix, "deleting token: ", err)
switch err {
switch {
// This means that token is invalid anyway
case core.ErrUnauthorized:
case core.ErrBadRequest:
case core.ErrServerInternal:
case errors.Is(err, core.ErrUnauthorized):
case errors.Is(err, core.ErrBadRequest):
case errors.Is(err, core.ErrServerInternal):
return &pb.Payload{
Type: internal.CodeInternalError,
}, nil
Expand All @@ -64,11 +64,13 @@ func (r *RPC) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.Payload, er

if err := r.api.Logout(tokenData.Token); err != nil {
log.Println(internal.ErrorPrefix, "logging out: ", err)
switch err {
switch {
// This means that token is invalid anyway
case core.ErrUnauthorized:
case core.ErrBadRequest:
case core.ErrServerInternal:
case errors.Is(err, core.ErrUnauthorized):
case errors.Is(err, core.ErrBadRequest):
// NordAccount tokens do not work with Logout endpoint and return ErrNotFound
case errors.Is(err, core.ErrNotFound):
case errors.Is(err, core.ErrServerInternal):
return &pb.Payload{
Type: internal.CodeInternalError,
}, nil
Expand Down

0 comments on commit eee8297

Please sign in to comment.