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

Implement user authentication #56

Merged
merged 10 commits into from
Oct 28, 2023
Merged

Conversation

Madhawa97
Copy link
Member

@Madhawa97 Madhawa97 commented Oct 9, 2023

Purpose

The purpose of this PR is to fix #55

Goals

Implement a robust and user-friendly login mechanism that allows users to securely log in using their email and password credentials.

Approach

Implement a login mechanism that allows users to log in using their credentials (email and password) while utilizing HTTP-only Cookies for enhanced security.
Upon successful authentication, save the authenticated user's data in context. This context should be accessible from any part of the application, ensuring that user-specific information is available where needed.

Screenshots

image

Checklist

  • This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • I have read and understood the development best practices guidelines ( http://bit.ly/sef-best-practices )
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Related PRs

Test environment

Node v18, macOS latest, chrome latest

Learning

User Authentication, Typescript, useContext

@Madhawa97 Madhawa97 requested a review from anjula-sack October 9, 2023 14:41
src/components/Layout/Navbar/Navbar.tsx Outdated Show resolved Hide resolved
src/components/Layout/Navbar/Navbar.tsx Outdated Show resolved Hide resolved
src/contexts/UserContext.tsx Show resolved Hide resolved
src/contexts/UserContext.tsx Outdated Show resolved Hide resolved
src/components/JoinUsDialog/JoinUsDialog.tsx Outdated Show resolved Hide resolved
src/components/Layout/Navbar/Navbar.tsx Outdated Show resolved Hide resolved
src/components/JoinUsDialog/JoinUsDialog.tsx Outdated Show resolved Hide resolved
src/App.tsx Outdated
const App: React.FC = () => {
const { user, setUser } = useContext(UserContext);

user !== null && console.log('user is authenticated');
Copy link
Member

Choose a reason for hiding this comment

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

Move this into useEffect

Copy link
Member Author

@Madhawa97 Madhawa97 Oct 25, 2023

Choose a reason for hiding this comment

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

the useEffect was defined in the UserProvider to invoke the getUser() each time the UserProvider mounts.
But as requested I changed it to invoke the getUser() each time the App mounts.
and the getUser() has also been sent to the App via Context. Could you let me know which way is correct/preferred?

@Madhawa97 Madhawa97 marked this pull request as ready for review October 25, 2023 16:03
@Madhawa97 Madhawa97 requested a review from anjula-sack October 25, 2023 16:03
src/components/Layout/Navbar/Navbar.tsx Outdated Show resolved Hide resolved
src/components/Layout/Navbar/Navbar.tsx Outdated Show resolved Hide resolved
src/components/LoginModal/index.tsx Outdated Show resolved Hide resolved
src/components/LoginModal/index.tsx Outdated Show resolved Hide resolved
@Madhawa97 Madhawa97 requested a review from anjula-sack October 27, 2023 14:47
Copy link
Member

@anjula-sack anjula-sack left a comment

Choose a reason for hiding this comment

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

Thank you! @Madhawa97

@anjula-sack anjula-sack merged commit 17f168a into sef-global:main Oct 28, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementing user authentication
2 participants