-
Notifications
You must be signed in to change notification settings - Fork 0
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
User accounts #345
User accounts #345
Conversation
ui/package.json
Outdated
@@ -84,7 +86,7 @@ | |||
"generate-exh-pairs": "node ./scripts/writeECBExchangePairsToJSON.js", | |||
"generate-fundamentals": "node ./scripts/writeBulkFundamentalsDataToJSON.js", | |||
"find-missing-gbonds": "node ./scripts/findMissingGBonds.js", | |||
"preinstall": "cd ../packages/dcf-react && npm install", | |||
"preinstall": "cd ../packages/dcf-react && npm install && cd ../auth && npm install", |
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.
Can remove
ui/src/components/Authentication.jsx
Outdated
FORGOTTEN_PASSWORD: "FORGOTTEN_PASSWORD", | ||
}; | ||
|
||
const StyledBox = styled(Box)(() => ({ |
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.
We are using Material UI v5.x.
Please bookmark this docs for it: https://next.material-ui.com/getting-started/usage/
And in this version we can not use styled as it does not work with SSR and gatsby.
See this issue I created: mui/material-ui#25312
The solution is to use Box with the sx prop. https://next.material-ui.com/system/basics/#heading-the-sx-prop
ui/src/components/Form.styles.js
Outdated
@@ -0,0 +1,24 @@ | |||
import { makeStyles } from "@material-ui/core"; | |||
|
|||
export const useFormStyles = makeStyles((theme) => ({ |
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.
Cannot use this. Same issue as styled. You can use sx
prop and target the classes instead.
If you want to share styles I would recommend to create a separate react component with the sx prop.
ui/src/components/Header.jsx
Outdated
|
||
const rightLinks = [ | ||
const rightLinks = (isAuthenticated) => [ |
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.
rightLinks
-> getRightLinks
<div className={classes.paper}> | ||
<TracktakLogoSvg /> | ||
<Typography component="h1" variant="h5"> | ||
Sign up |
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.
Don't add it to this ticket, we will do it in a follow up because I think we can not do it for non-EU countries but we need a checkbox in this form component that says something like this.
[] Please tick if you consent to getting the occasional feature update or marketing email.
Let's do this after though. I ain't scared of no GDPRR!!
ui/src/layouts/index.js
Outdated
{children} | ||
<TTSnackbar /> | ||
</Root> | ||
<ProvideAuth> |
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 Provider should go in the sharedGatsby
file.
That is the absolute root file for all pages.
|
||
const SignIn = () => { | ||
const handleSuccess = () => { | ||
navigate("/"); |
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 we will want to redirect to the page the user just came from?
Or if they have no previous page then I guess the home page.
ui/src/pages/sign-in.jsx
Outdated
<> | ||
<Helmet> | ||
<title>{getTitle("Sign in")}</title> | ||
<link rel="canonical" href={`${resourceName}/sign-up`} /> |
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.
sign-up -> sign-in
ui/src/pages/sign-out.jsx
Outdated
const { session, signOut } = useAuth(); | ||
|
||
const handleSuccess = () => { | ||
navigate("/"); |
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.
Same comment as above. But does sign out need to be a page?
Usually sign outs are just buttons.
ui/src/theme.js
Outdated
@@ -22,6 +22,9 @@ let theme = createMuiTheme({ | |||
dark: "#41407d", | |||
contrastText: "#fff", | |||
}, | |||
icons: { | |||
facebook: "#3B5998" |
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.
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.
We should keep facebook & google icons as "their" colors for user accounts.
…igning in brings you to previous page or home page if one doesn't exist
Completed forgot password flow in Modal mode Handle redirects for sign-in / sign-up / forgot-password when user is already authenticated
…with PreventUserExistenceErrors for security
I need to ensure that there are no nasty AWS errors being displayed to user, think most are ok but so far need to fix the weak password error, don't want user's seeing this: |
Yeah, also don't want to leak backend errors at all to users because a security concern. Should just be generic user erros. |
region: 'eu-west-2' | ||
}); | ||
const params = { | ||
FunctionName: 'cognitoEmailAuthFlow-ChangePassword-P8M0410OHSTW', // TODO - better way to get name? |
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.
If someone destroys the lambda and re-creates it I presume it breaks this code because of the hash at the end?
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.
It would have yep. Changed it to not use a auto-generated name
{ | ||
"name": "cognito-email-auth-backend", | ||
"version": "1.0.0", | ||
"description": "This is a sample template for cognito-sam - Below is a brief explanation of what we have generated for you:", |
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.
cognito-sam? :D. should this be cognito-tracktak? And the same for 'sam' references below
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.
haha its 'Serverless Application Model'
https://docs.aws.amazon.com/serverless-application-model/index.html
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.
haha didn't realise
} from "amazon-cognito-identity-js"; | ||
|
||
const POOL_CONFIG = { | ||
UserPoolId: process.env.GATSBY_COGNITO_USER_POOL_ID, |
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.
We will need to add these to our .env to test and to GitHub settings secrets for staging deploy.
Could you send all .env variables to us over slack and delete the message once you do?
navigate(-1); | ||
}; | ||
|
||
return ( |
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.
Very nice code :)
}} | ||
> | ||
<TracktakLogoSvg /> | ||
<Typography component="h1" variant="h5"> |
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.
You don't need component="h1"
, it doesn't do anything here I don't think.
SEO purposes google doesn't care what heading type is used
ui/src/components/Header.jsx
Outdated
textTransform: "none", | ||
fontSize: "16px", | ||
fontWeight: "bold", | ||
color: "#313450", |
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.
should we use theme here?
you can do this:
color: (theme) => theme.palette.blahblah
ui/src/components/Header.jsx
Outdated
|
||
const buttonStyle = { | ||
textTransform: "none", | ||
fontSize: "16px", |
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.
Think maybe should use theme here too?
ui/src/components/SignInForm.jsx
Outdated
}} | ||
> | ||
<TracktakLogoSvg /> | ||
<Typography component="h1" variant="h5"> |
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.
same comment as other
ui/src/components/SignUpForm.jsx
Outdated
}} | ||
> | ||
<TracktakLogoSvg /> | ||
<Typography component="h1" variant="h5"> |
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.
same comment as other
ui/src/hooks/useAuth.js
Outdated
}; | ||
|
||
const onNewPasswordRequired = () => { | ||
console.error("New password required"); // TODO |
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.
TODO here
const SignIn = ({ location }) => { | ||
const { isAuthenticated } = useAuth(); | ||
|
||
const navigateToPreviousPage = useCallback(() => { |
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.
is useCallback needed here? I probably wouldn't use it if it's not needed. Bugs are more likely.
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.
added because its used in an effect below
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.
- There's should be margin between "tracktak" logo and "Sign in"/Sign up /Forgot password/Reset password text and the title text should have color:#313450 (use in theme.js).
- Button's text should be in lower case and have fontSize and make buttons less massive. So it should be the same format as in the landing page to keep it consistent, example in SearchSection.jsx. If we need to make the button more reusable, put it in the theme.js.
- Same applies to Forgot password/Resetting password section, buttons should be the same format as landing page.
- Better error messages if user dublicates their credentials. Example, if I register with the same email again.
- When resetting the password, haven't received verification code via my email.
- If I input fake code, we should have better error message, maybe like this: "The code has expired"?
|
No description provided.