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

Frontend: Hide Elements based on Login #167

Merged
merged 13 commits into from
Feb 14, 2024
Merged

Frontend: Hide Elements based on Login #167

merged 13 commits into from
Feb 14, 2024

Conversation

ansengarvin
Copy link
Collaborator

@ansengarvin ansengarvin commented Feb 13, 2024

ui_auth_lock.mp4

How to test

Since there are new dependencies, you must do the soft_restart shell command to install and refresh the packages. To test the changes, you should log into to the website with email "test" and password "test".

What this PR does

  • Stores the user's login status in a svelte store, allowing the website to keep track of whether the user is logged in
  • Automatically checks if cookie exists when browser is refreshed; If it does, sets svelte store to login
  • Deletes authentication cookie if user visits login page (e.g. if user logs out), and also clears stored login status
  • Changes login button text between "login" and "logout" depending on user login status
  • Hides / shows upload button based on user login status
  • Hides / shows edit button based on user login status
  • Automatically alerts the user and redirects them to home if they manually type in the URLs to the upload or edit pages
  • Changed the test user email and password both to "test", to make it easier to test.

Not addressed in this PR, but still needs to be done

  • Frontend needs to be changed to send authentication tokens to backend from the cookie
  • Backend needs to be changed to verify the authentication tokens prior to executing restricted requests (POST, PATCH, DELETE)
  • Unauthorized access to upload/edit pages should redirect to a 401 Unauthorized page (not yet implemented) instead of home
  • Some notification element should be created to better communicate to the user that they are logged in
  • We should probably create some sort of basic user profile (so users can know which account they are logged into)

New Dependencies

  • svelte-store

Closes #165
Closes #166

@ansengarvin ansengarvin marked this pull request as ready for review February 13, 2024 23:29
@ansengarvin ansengarvin changed the title Frontend: Login Changes Frontend: Hide Elements based on Login Feb 13, 2024
@xnought xnought self-requested a review February 14, 2024 01:07
Comment on lines 38 to 39
"svelte-store": "^0.0.2"
},
Copy link
Member

Choose a reason for hiding this comment

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

svelte store is already included in the svelte library, I'll remove this

Copy link
Member

@xnought xnought left a comment

Choose a reason for hiding this comment

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

Super excellent! Let's merge it

@xnought xnought merged commit 86f4a4d into main Feb 14, 2024
2 checks passed
@xnought xnought deleted the ui_auth_lock branch February 14, 2024 03:51
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.

Implement authentication-based UI changes Fix login page to delete cookies on load
2 participants