-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: breaking use account-js for authentication
BREAKING CHANGE: the authorization methods have been switched to account-js Signed-off-by: Akarshit Wal <akarshitwal@gmail.com>
- Loading branch information
Showing
32 changed files
with
2,981 additions
and
2,425 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,10 @@ | ||
CANONICAL_URL=http://localhost:4000 | ||
ENABLE_SPA_ROUTING=true | ||
BUILD_GRAPHQL_URL=http://localhost:3000/graphql | ||
EXTERNAL_GRAPHQL_URL=http://localhost:3000/graphql | ||
INTERNAL_GRAPHQL_URL=http://api.reaction.localhost:3000/graphql | ||
OAUTH2_ADMIN_PORT=4445 | ||
OAUTH2_ADMIN_URL=http://hydra.reaction.localhost:4445 | ||
OAUTH2_AUTH_URL=http://localhost:4444/oauth2/auth | ||
OAUTH2_CLIENT_ID=example-storefront | ||
OAUTH2_CLIENT_SECRET=CHANGEME | ||
OAUTH2_PUBLIC_LOGOUT_URL=http://localhost:4444/oauth2/sessions/logout | ||
OAUTH2_HOST=hydra.reaction.localhost | ||
OAUTH2_IDP_PUBLIC_CHANGE_PASSWORD_URL=http://localhost:4100/account/change-password?email=EMAIL&from=FROM | ||
OAUTH2_IDP_HOST_URL=http://identity.reaction.localhost:4100 | ||
OAUTH2_TOKEN_URL=http://hydra.reaction.localhost:4444/oauth2/token | ||
PORT=4000 | ||
SEGMENT_ANALYTICS_SKIP_MINIMIZE=true | ||
SEGMENT_ANALYTICS_WRITE_KEY=ENTER_KEY_HERE | ||
SESSION_MAX_AGE_MS=2592000000 | ||
SESSION_SECRET=CHANGEME | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE |
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 |
---|---|---|
@@ -1,21 +1,10 @@ | ||
CANONICAL_URL=http://localhost:4000 | ||
ENABLE_SPA_ROUTING=true | ||
BUILD_GRAPHQL_URL=http://localhost:3000/graphql | ||
EXTERNAL_GRAPHQL_URL=http://localhost:3000/graphql | ||
INTERNAL_GRAPHQL_URL=http://api.reaction.localhost:3000/graphql | ||
OAUTH2_ADMIN_PORT=4445 | ||
OAUTH2_ADMIN_URL=http://hydra.reaction.localhost:4445 | ||
OAUTH2_AUTH_URL=http://localhost:4444/oauth2/auth | ||
OAUTH2_CLIENT_ID=example-storefront | ||
OAUTH2_CLIENT_SECRET=CHANGEME | ||
OAUTH2_PUBLIC_LOGOUT_URL=http://localhost:4444/oauth2/sessions/logout | ||
OAUTH2_HOST=hydra.reaction.localhost | ||
OAUTH2_IDP_PUBLIC_CHANGE_PASSWORD_URL=http://localhost:4100/account/change-password?email=EMAIL&from=FROM | ||
OAUTH2_IDP_HOST_URL=http://identity.reaction.localhost:4100 | ||
OAUTH2_TOKEN_URL=http://hydra.reaction.localhost:4444/oauth2/token | ||
PORT=4000 | ||
SEGMENT_ANALYTICS_SKIP_MINIMIZE=true | ||
SEGMENT_ANALYTICS_WRITE_KEY=ENTER_KEY_HERE | ||
SESSION_MAX_AGE_MS=2592000000 | ||
SESSION_SECRET=CHANGEME | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE | ||
STRIPE_PUBLIC_API_KEY=ENTER_STRIPE_PUBLIC_KEY_HERE |
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 was deleted.
Oops, something went wrong.
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,86 @@ | ||
import React, { useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import FormControl from "@material-ui/core/FormControl"; | ||
import InputLabel from "@material-ui/core/InputLabel"; | ||
import Input from "@material-ui/core/Input"; | ||
import Button from "@material-ui/core/Button"; | ||
import red from "@material-ui/core/colors/red"; | ||
|
||
import getAccountsHandler from "../../lib/accountsServer.js"; | ||
import hashPassword from "../../lib/utils/hashPassword"; | ||
|
||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
"display": "flex", | ||
"flexDirection": "column", | ||
"& > *": { | ||
margin: theme.spacing(1) | ||
} | ||
}, | ||
error: { | ||
marginTop: theme.spacing(2), | ||
color: red[500], | ||
fontSize: "1.1em", | ||
textAlign: "center" | ||
}, | ||
resetButton: { | ||
marginTop: theme.spacing(4) | ||
} | ||
})); | ||
|
||
/** | ||
* | ||
* @param {Object} props of the structure { closeModal: function called to close the modal } | ||
* @returns {Object} the component to render for updating password | ||
*/ | ||
export default function ChangePassword(props) { | ||
const { closeModal } = props; | ||
const classes = useStyles(); | ||
const [oldPassword, setOldPassword] = useState(""); | ||
const [newPassword, setNewPassword] = useState(""); | ||
const [error, setError] = useState(""); | ||
const { passwordClient } = getAccountsHandler(); | ||
|
||
const handleOldPasswordChange = (event) => { | ||
setOldPassword(event.target.value); | ||
}; | ||
const handleNewPasswordChange = (event) => { | ||
setNewPassword(event.target.value); | ||
}; | ||
|
||
const handleChangePassword = async () => { | ||
try { | ||
await passwordClient.changePassword(hashPassword(oldPassword), hashPassword(newPassword)); | ||
closeModal(); | ||
} catch (err) { | ||
setError(err.message); | ||
} | ||
}; | ||
return ( | ||
<form className={classes.root} noValidate> | ||
<h1>Change password</h1> | ||
<FormControl> | ||
<InputLabel htmlFor="old-password">Old Password</InputLabel> | ||
<Input id="old-password" aria-describedby="old-password" onChange={handleOldPasswordChange} value={oldPassword} | ||
type="password" | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<InputLabel htmlFor="new-password">New Password</InputLabel> | ||
<Input id="new-password" aria-describedby="new-password" onChange={handleNewPasswordChange} value={newPassword} | ||
type="password" | ||
/> | ||
</FormControl> | ||
{!!error && <div className={classes.error}>{error}</div>} | ||
<Button className={classes.resetButton} onClick={handleChangePassword} color="primary" variant="contained" | ||
tabIndex="0" role="button" | ||
>Change</Button> | ||
</form> | ||
); | ||
} | ||
|
||
ChangePassword.propTypes = { | ||
closeModal: PropTypes.func | ||
}; |
Oops, something went wrong.