+
+ /**
+ * Update the context for where the user is coming from to manage API tokens.
+ * (Track of location for correct return redirects)
+ */
+ protected function updateContext(Request $request): void
+ {
+ $context = $request->query('context');
+ if ($context) {
+ session()->put('api-token-context', $context);
+ }
+ }
+
+ /**
+ * Get the redirect path for the current api token editing session.
+ * Attempts to recall the context of where the user is editing from.
+ */
+ protected function getRedirectPath(User $relatedUser): string
+ {
+ $context = session()->get('api-token-context');
+ if ($context === 'settings') {
+ return $relatedUser->getEditUrl('#api_tokens');
+ }
+
+ return url('/my-account/auth#api_tokens');
+ }