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

User accounts #345

Merged
merged 25 commits into from
May 26, 2021
Merged

User accounts #345

merged 25 commits into from
May 26, 2021

Conversation

MartinDawson
Copy link
Contributor

No description provided.

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",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can remove

FORGOTTEN_PASSWORD: "FORGOTTEN_PASSWORD",
};

const StyledBox = styled(Box)(() => ({
Copy link
Contributor Author

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

@@ -0,0 +1,24 @@
import { makeStyles } from "@material-ui/core";

export const useFormStyles = makeStyles((theme) => ({
Copy link
Contributor Author

@MartinDawson MartinDawson May 12, 2021

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.


const rightLinks = [
const rightLinks = (isAuthenticated) => [
Copy link
Contributor Author

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
Copy link
Contributor Author

@MartinDawson MartinDawson May 12, 2021

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!!

{children}
<TTSnackbar />
</Root>
<ProvideAuth>
Copy link
Contributor Author

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("/");
Copy link
Contributor Author

@MartinDawson MartinDawson May 12, 2021

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.

<>
<Helmet>
<title>{getTitle("Sign in")}</title>
<link rel="canonical" href={`${resourceName}/sign-up`} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sign-up -> sign-in

const { session, signOut } = useAuth();

const handleSuccess = () => {
navigate("/");
Copy link
Contributor Author

@MartinDawson MartinDawson May 12, 2021

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"
Copy link
Contributor Author

@MartinDawson MartinDawson May 12, 2021

Choose a reason for hiding this comment

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

Should we keep it consistent with the landing page and make it green instead? Or will that look weird?

image

Copy link
Contributor

@krisolchova krisolchova May 13, 2021

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.

masesor added 7 commits May 16, 2021 16:56
…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
@masesor
Copy link
Contributor

masesor commented May 18, 2021

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: "1 validation error detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6"

@MartinDawson
Copy link
Contributor Author

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: "1 validation error detected: Value at 'password' failed to satisfy constraint: Member must have length greater than or equal to 6"

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?
Copy link
Contributor Author

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?

Copy link
Contributor

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:",
Copy link
Contributor Author

@MartinDawson MartinDawson May 19, 2021

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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,
Copy link
Contributor Author

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 (
Copy link
Contributor Author

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">
Copy link
Contributor Author

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

textTransform: "none",
fontSize: "16px",
fontWeight: "bold",
color: "#313450",
Copy link
Contributor Author

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


const buttonStyle = {
textTransform: "none",
fontSize: "16px",
Copy link
Contributor Author

@MartinDawson MartinDawson May 19, 2021

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?

}}
>
<TracktakLogoSvg />
<Typography component="h1" variant="h5">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as other

}}
>
<TracktakLogoSvg />
<Typography component="h1" variant="h5">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as other

};

const onNewPasswordRequired = () => {
console.error("New password required"); // TODO
Copy link
Contributor Author

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(() => {
Copy link
Contributor Author

@MartinDawson MartinDawson May 19, 2021

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.

Copy link
Contributor

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

@krisolchova krisolchova self-requested a review May 22, 2021 12:39
Copy link
Contributor

@krisolchova krisolchova left a comment

Choose a reason for hiding this comment

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

  1. 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).
    image
  2. 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.
  3. Same applies to Forgot password/Resetting password section, buttons should be the same format as landing page.
  4. Better error messages if user dublicates their credentials. Example, if I register with the same email again.
  5. When resetting the password, haven't received verification code via my email.
  6. If I input fake code, we should have better error message, maybe like this: "The code has expired"?
    image

@masesor
Copy link
Contributor

masesor commented May 24, 2021

  1. For the buttons, do you mean not have them full width to match the text fields? Similar to this:
    buttons

  2. What day did you try this? Will check the logs to try determine why

  3. What error did you get? Should have got below:

Capture

@krisolchova
Copy link
Contributor

krisolchova commented May 24, 2021

  1. For the buttons, do you mean not have them full width to match the text fields? Similar to this:
    Ah yeah, forgot to mention. The button itself looks fine, just needs the full width then.
  1. What day did you try this? Will check the logs to try determine why
    Still didn't receive any code via email.
  2. What error did you get? Should have got below:

@MartinDawson MartinDawson merged commit aeffcdb into main May 26, 2021
@MartinDawson MartinDawson deleted the user-accounts branch May 26, 2021 17:55
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.

3 participants