Skip to content

How to auth user in react application? #10

Closed Answered by FreePhoenix888
FreePhoenix888 asked this question in Q&A
Discussion options

You must be logged in to vote

Use deep.login and pass token there and pass gql path to

						<ApolloClientTokenizedProvider
							options={{
								client: 'deeplinks-app',
								path: gqlPath,
								ssl: isSsl,
								ws: !!process?.browser,
							}}
						>

Working code:

function LoginOrPage({ setGqlPath }) {
  const deep = useDeep();
  const [isAuthorized, setIsAuthorized] = useState(false);

  useEffect(() => {
    self["deep"] = deep
    if (deep.linkId !== 0) {
      setIsAuthorized(true);
    } else {
      setIsAuthorized(false);
    }
  }, [deep]);

  return isAuthorized ? (
    <Page />
  ) : (
    <LoginCard
      onSubmit={(arg) => {
        console.log({arg})
        setGqlPath(arg.gqlPath);
        

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@Konard
Comment options

@FreePhoenix888
Comment options

FreePhoenix888 May 5, 2023
Maintainer Author

@FreePhoenix888
Comment options

FreePhoenix888 May 5, 2023
Maintainer Author

@FreePhoenix888
Comment options

FreePhoenix888 May 5, 2023
Maintainer Author

Answer selected by FreePhoenix888
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants