-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
d4536d7
to
d780f25
Compare
There was a problem hiding this 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.
There was a problem hiding this comment.
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>
)
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Changed!
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Changed!
There was a problem hiding this comment.
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
)}`;
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
2117ed8
to
64a61f3
Compare
57de75c
to
b2629ab
Compare
zenhub 1644