-
Notifications
You must be signed in to change notification settings - Fork 22
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
689 authentication #1320
Merged
Merged
689 authentication #1320
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
92cd980
Passwordless login prototype. First stab at adding auth client to con…
24b7789
Merge branch 'master' into 689-authentication
f74af9f
Begin building out AuthService SessionStorage API and Context object …
ac1abee
Read sessionStorage for user session upon loading page
7d8f932
689 Create logout functionality. Create call to Auth0 that resets acc…
4e46dbe
689 add sign out functionality and update sign-in/sign-up UI and veri…
7bf9444
Complete basic user sign up flow and check if user exists prior to si…
b541a93
Update user exists route
bbf2da2
PR cleanup, clarifications, and comments.
d763060
Rename sign in and sign out pages and routes to log in and log out
67e35a8
689 Change a few instances of sign-in to log-in
76f01dc
689 save user to database after creating them in Auth0
84b26d0
689 Run prettier and lean up auth PR
e732230
689 no longer check if user exists prior to creating user. For variou…
9d7f87c
Create user endpoint argument name change
379cd02
Prettier
2182b67
689 use config value for logout redirect param
a1f1d3b
Merge branch 'master' of https://github.com/ShelterTechSF/askdarcel-w…
605e87a
Add types to AppContext object
c4b4ba7
689 migrate AuthService and SessionCacher from class based component …
b169d0c
More misc PR updates
7c8ae80
689 combine useAppContext and AppProvider files. Remove isAuthenticat…
schroerbrian bf686b4
Prettier
schroerbrian e3631cf
689 moar PR cleanup
schroerbrian 8554f21
Lint fix
schroerbrian 8b9be56
689 PR feedback and cleanup
schroerbrian 97cde91
Fix argument name
schroerbrian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@import "~styles/utils/_helpers.scss"; | ||
|
||
.authPage { | ||
display: grid; | ||
grid-column: 2 / span 10; | ||
gap: 10px; | ||
margin: 20px; | ||
} | ||
|
||
.verificationDigits { | ||
display: flex; | ||
width: 400px; | ||
} | ||
|
||
.title { | ||
font-size: 24px; | ||
} | ||
|
||
.authForm { | ||
width: 66%; | ||
display: grid; | ||
gap: 8px; | ||
} | ||
|
||
.authFormButton { | ||
max-width: 300px; | ||
margin-top: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { Button } from "components/ui/inline/Button/Button"; | ||
import { useAppContext, passwordlessLogin, passwordlessStart } from "utils"; | ||
|
||
import { VerificationModal } from "./VerificationModal"; | ||
|
||
import styles from "./Auth.module.scss"; | ||
|
||
export const LoginPage = () => { | ||
const [modalIsOpen, setModalIsOpen] = useState(false); | ||
const [email, setEmail] = useState(""); | ||
const { authClient } = useAppContext(); | ||
|
||
const logIn = (evt: React.SyntheticEvent) => { | ||
evt.preventDefault(); | ||
passwordlessStart(authClient, email).then(() => { | ||
setModalIsOpen(true); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className={styles.authPage}> | ||
<h1 className={styles.title}>For Case Managers</h1> | ||
<Link to="/sign-up">New here? Sign up!</Link> | ||
<p> | ||
We want to make sure that your account information is safe, so you will | ||
be sent a verification code to your email each time you log in. Please | ||
enter in your email address and then check your email to find a 6 digit | ||
verification code. | ||
</p> | ||
<form className={styles.authForm} onSubmit={logIn}> | ||
<input | ||
type="text" | ||
name="email" | ||
placeholder="Email address" | ||
value={email} | ||
onChange={(evt) => { | ||
setEmail(evt.target.value); | ||
}} | ||
/> | ||
<Button addClass={styles.authFormButton} buttonType="submit"> | ||
Sign In | ||
</Button> | ||
</form> | ||
|
||
<VerificationModal | ||
email={email} | ||
modalIsOpen={modalIsOpen} | ||
setModalIsOpen={setModalIsOpen} | ||
verifyCode={(code) => passwordlessLogin(authClient, email, code)} | ||
resendCode={() => passwordlessStart(authClient, email)} | ||
buttonText="Log in" | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { useEffect } from "react"; | ||
import { Redirect } from "react-router-dom"; | ||
import * as AuthService from "utils/AuthService"; | ||
import { useAppContext } from "../../utils"; | ||
|
||
import Config from "../../config"; | ||
|
||
export const LogoutPage = () => { | ||
const context = useAppContext(); | ||
const { setAuthState } = context; | ||
const { authClient } = context; | ||
|
||
useEffect(() => { | ||
AuthService.logout(authClient, Config.AUTH0_CLIENT_ID, setAuthState); | ||
}); | ||
|
||
return <Redirect to="/" />; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this is a not necessarily helpful, and I am getting tired of the linter yelling at me every time I need to change a function from being implicitly returned to being in block body when extra logic is needed