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

1644 login redirect functionality #1725

Merged
merged 9 commits into from
Jun 28, 2023

Conversation

JoshLarouche
Copy link
Contributor

@JoshLarouche JoshLarouche force-pushed the 1644-login-redirect-functionality branch 2 times, most recently from d4536d7 to d780f25 Compare June 21, 2023 16:01
Copy link
Contributor

@Sepehr-Sobhani Sepehr-Sobhani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Job 👍 Just a couple of changes are required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do a bit of refactoring on lines 37 through 54, something like:

  let rightSide = isLoggedIn ? (
    <>
      {userProfileComponent}
      <LogoutForm />
    </>
  ) : (
    router.pathname !== "/" && (
      <div
        style={{
          display: "flex",
          flexDirection: "row",
          gap: "1.25em",
        }}
      >
        <LoginForm />
        {showExternalOperatorsLogin && <LoginForm isExternal={true} />}
      </div>
    )
  );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Changed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also simplify things here a little bit and have less code to maintain:

      <form id="login-buttons" action={loginURI} method="post">
        <Button
          type="submit"
          variant={
            router.pathname.includes("login-redirect")
              ? "secondary-inverse"
              : isExternal && "secondary"
          }
        >
          {isExternal ? "External User Login" : "Administrator Login"}
        </Button>
      </form>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Changed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we need to tweak loginURI too, currently, this part of the AC is not in place:
Then I am redirected back to the page I was trying to get to.
I've played with the code and something like this could be a solution:

  let loginURI = "/login";

  if (router.query.redirectTo)
    loginURI += `?redirectTo=${encodeURIComponent(
      router.query.redirectTo as string
    )}`;
  else if (isExternal)
    loginURI += `?redirectTo=${encodeURIComponent(
      getExternalUserLandingPageRoute().pathname as string
    )}`;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch I tested mostly with the admin login! Changed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it would be advantageous to conduct a test here on the redirect functionality for external users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion with @Sepehr-Sobhani it was determined that it does not make sense to test this for now until we add more external user functionality.

@JoshLarouche JoshLarouche force-pushed the 1644-login-redirect-functionality branch from 2117ed8 to 64a61f3 Compare June 26, 2023 18:44
@JoshLarouche JoshLarouche force-pushed the 1644-login-redirect-functionality branch from 57de75c to b2629ab Compare June 27, 2023 15:16
@JoshLarouche JoshLarouche merged commit 14c4af1 into develop Jun 28, 2023
16 checks passed
@JoshLarouche JoshLarouche deleted the 1644-login-redirect-functionality branch June 28, 2023 15:24
@bc-cas-shipit bc-cas-shipit bot temporarily deployed to dev June 28, 2023 15:45 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants