MCPcopy Create free account
hub / github.com/algolia/cli / ReauthenticateIfExpired

Function ReauthenticateIfExpired

pkg/auth/authenticate.go:33–49  ·  view source on GitHub ↗

ReauthenticateIfExpired checks if err is a session-expired error from the API. If so, it clears the invalid token and triggers the login flow.

(
	io *iostreams.IOStreams,
	client *dashboard.Client,
	err error,
)

Source from the content-addressed store, hash-verified

31// ReauthenticateIfExpired checks if err is a session-expired error from the API.
32// If so, it clears the invalid token and triggers the login flow.
33func ReauthenticateIfExpired(
34 io *iostreams.IOStreams,
35 client *dashboard.Client,
36 err error,
37) (string, error) {
38 if !errors.Is(err, dashboard.ErrSessionExpired) {
39 return "", err
40 }
41
42 cs := io.ColorScheme()
43 ClearToken()
44 fmt.Fprintf(io.Out, "%s Session expired.\n", cs.WarningIcon())
45
46 // No flow tracker: this re-authentication belongs to the calling flow,
47 // not to an `auth login` funnel.
48 return RunOAuth(io, client, false, true, nil)
49}

Callers 7

callWithReauthFunction · 0.92
runUpdateCmdFunction · 0.92
runListCmdFunction · 0.92
runSelectCmdFunction · 0.92
callWithReauthFunction · 0.92
runPlansCmdFunction · 0.92

Calls 4

ClearTokenFunction · 0.85
RunOAuthFunction · 0.85
ColorSchemeMethod · 0.80
WarningIconMethod · 0.80

Tested by

no test coverage detected