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

DAH-2876 feat: allow redirect after sign in #2435

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

cade-exygy
Copy link
Collaborator

@cade-exygy cade-exygy commented Nov 26, 2024

Description

If a user tries to go to the my-account, account-settings, or my-applications and is not signed in: redirect to sign in page, show banner. Once the login happens, the user is redirected to the page they were trying to access prior.

Jira ticket

https://sfgovdt.jira.com/browse/DAH-2876

Checklist before requesting review

Version Control

  • branch name begins with angular if it contains updates to Angular code
  • branch name contains the Jira ticket number
  • PR name follows type: TICKET-NUMBER Description format, e.g. feat: DAH-123 New Feature

Code quality

  • the set of changes is small
  • all automated code checks pass (linting, tests, coverage, etc.)
  • code irrelevant to the ticket is not modified e.g. changing indentation due to automated formatting
  • if the code changes the UI, it matches the UI design exactly
  • if the changes include human translations, follow the human translations process

Review instructions

  • instructions specify which environment(s) it applies to
  • instructions work for PA testers
  • instructions have already been performed at least once

Request review

  • PR has needs review label
  • Use Housing Eng group to automatically assign reviewers, and/or assign specific engineers
  • If time sensitive, notify engineers in Slack

Review Instructions

  • On the review app:
  • While signed out, manually enter the restricted url: /my-account?react=true
  • It should try to load the page, but then redirect back to /sign-in
  • You should see the banner
  • Sign In to an account: [email protected] / test1234
  • Once you are signed in, you should be redirected
  • Try this with /my-account, /account-settings, and /my-applications

Test edge cases like signing out, triggering other banners, etc

@hshaosf hshaosf temporarily deployed to dahlia-webapp-pr-2435 November 26, 2024 17:50 Inactive
@cade-exygy cade-exygy changed the title feat: allow redirect after sign in DAH-2876 feat: allow redirect after sign in Nov 26, 2024
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 November 27, 2024 20:39 Inactive
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 3, 2024 16:49 Inactive
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 9, 2024 17:49 Inactive
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 10, 2024 19:32 Inactive
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 10, 2024 21:05 Inactive
@cade-exygy cade-exygy marked this pull request as ready for review December 10, 2024 21:05
@cade-exygy cade-exygy requested review from a team, tallulahkay and jimlin-sfgov and removed request for a team December 10, 2024 21:12
@cade-exygy cade-exygy added the needs review Pull request needs review label Dec 10, 2024
@tallulahkay
Copy link
Contributor

@cade-exygy could you try to up the code cov here?

@jimlin-sfgov jimlin-sfgov temporarily deployed to dahlia-webapp-pr-2435 December 11, 2024 18:16 Inactive
app/javascript/util/routeUtil.ts Outdated Show resolved Hide resolved
@@ -456,7 +457,8 @@ const AccountSettingsPage = () => {
const { profile, loading, initialStateLoaded } = React.useContext(UserContext)

if (!profile && !loading && initialStateLoaded) {
// TODO: Redirect to React sign in page and show a message that user needs to sign in
window.sessionStorage.setItem("redirect", "settings")
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: We're using sessionStorage across various files, and it's not immediately obvious what arguments for setItem mean. We should look into consolidating all routing-related sessionStorage usage into a single file, probably in routeUtil.ts.

@@ -62,7 +63,8 @@ const MyAccount = (_props: MyAccountProps) => {
const { profile, loading, initialStateLoaded } = React.useContext(UserContext)

if (!profile && !loading && initialStateLoaded) {
// TODO: Redirect to React sign in page and show a message that user needs to sign in
window.sessionStorage.setItem("redirect", "account")
setSiteAlertMessage(t("signIn.loginRequired"), "secondary")
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: We're well along this path now, but in the future we should look into using constants instead of strings for things like "redirect", "account", and "secondary".

@@ -198,6 +199,8 @@ const MyApplications = () => {
}, [authLoading, initialStateLoaded, profile])

if (!profile && !authLoading && initialStateLoaded) {
window.sessionStorage.setItem("redirect", "applications")
setSiteAlertMessage(t("signIn.loginRequired"), "secondary")
Copy link
Collaborator

@jimlin-sfgov jimlin-sfgov Dec 11, 2024

Choose a reason for hiding this comment

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

issue: I think something here needs to be updated to address the following issue: the "You must be signed in..." banner shows up when I click the sign out button
Screenshot 2024-12-11 at 10 35 31 AM

Copy link
Contributor

@tallulahkay tallulahkay Dec 12, 2024

Choose a reason for hiding this comment

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

(I think) This has been fixed in main and the fix just hasn't been pulled into this branch yet

@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 16, 2024 20:07 Inactive
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 16, 2024 20:08 Inactive
@cade-exygy cade-exygy temporarily deployed to dahlia-webapp-pr-2435 December 16, 2024 20:24 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Pull request needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants