Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Documentation #337

Open
jnt0r opened this issue Jan 13, 2022 · 1 comment
Open

Expand Documentation #337

jnt0r opened this issue Jan 13, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@jnt0r
Copy link
Owner

jnt0r commented Jan 13, 2022

More detailed and structured documentation. Maybe describe all available methods and properties.

Possibly with GitHub pages or as GitHub wiki?

@jnt0r jnt0r added the documentation Improvements or additions to documentation label Jan 13, 2022
@rimutaka
Copy link

@jnt0r , think more examples and an explanation of the flow in the README would be enough for most users.
I'm happy to help you polish it if you write a draft. I just don't have enough understanding of how it all works to do it myself.

Does this look right to you or is there a better way of doing it?

// only authenticated users may access this Vue app
// the auth should apply to the entire site, not just select routes
router.beforeEach(async () => {
  // an early exit if the user has been auth'd earlier
  if (AuthenticationState && AuthenticationState.authenticated) {
    return true;
  }

  // it could that the authentication is still in progress
  // the problem with this call is that it never returns if authenticated
  const isAuthed = await AuthenticationState.getAuthenticatedAsPromise();

  // try to log in if not authenticated up to this point
  if (!isAuthed) {
    // this redirects to Auth0 login form, but sometimes it just logs me in
    // even if I delete all auth0 cookies
    auth.loginWithRedirect();
  }

  // recheck if the user was logged in successfully
  // redirect to a public welcome page on failure
  if (!auth || !auth.authenticated) {
    console.log("failed to auth");
    location.assign("https://stackmuncher.com");
  }

  // all navigation
  return true;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants