Signout deletes a user session on the server side
(ctx context.DnoteCtx, sessionKey string)
| 595 | |
| 596 | // Signout deletes a user session on the server side |
| 597 | func Signout(ctx context.DnoteCtx, sessionKey string) error { |
| 598 | // Create a client that shares the transport (and thus rate limiter) from ctx.HTTPClient |
| 599 | // but doesn't follow redirects |
| 600 | var hc *http.Client |
| 601 | if ctx.HTTPClient != nil { |
| 602 | hc = &http.Client{ |
| 603 | Transport: ctx.HTTPClient.Transport, |
| 604 | CheckRedirect: func(req *http.Request, via []*http.Request) error { |
| 605 | return http.ErrUseLastResponse |
| 606 | }, |
| 607 | } |
| 608 | } else { |
| 609 | log.Warnf("No HTTP client configured for signout - falling back\n") |
| 610 | hc = &http.Client{ |
| 611 | CheckRedirect: func(req *http.Request, via []*http.Request) error { |
| 612 | return http.ErrUseLastResponse |
| 613 | }, |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | opts := requestOptions{ |
| 618 | HTTPClient: hc, |
| 619 | ExpectedContentType: &contentTypeNone, |
| 620 | } |
| 621 | _, err := doAuthorizedReq(ctx, "POST", "/v3/signout", "", &opts) |
| 622 | if err != nil { |
| 623 | return errors.Wrap(err, "making http request") |
| 624 | } |
| 625 | |
| 626 | return nil |
| 627 | } |