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

[#21] [#8] As a user, I can login with an email and password #35

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

liamstevens111
Copy link
Owner

@liamstevens111 liamstevens111 commented Feb 16, 2023

What happened 👀

  • Setup Base Adapter and Auth Adapter (includes client_id, client_secret) for performing requests with RequestManager
  • Setup environment variables for base URL and client and secret
  • Perform login request and store access_token and refresh_token from response in LocalStorage
  • Perform validation and handle API error and success responses on UI
  • Tests / Mocks for Login page, API requests + Adapters etc

Protecting survey pages and redirecting to homepage has been separated to another issue here: #25

Maintaining a session by obtaining a new access token with refresh token been moved to separate ticket here: #36

Insight 📝

  • Used global localStorage mock due to being client wide library and unable to be mocked naturally by Jest
  • Used nock package for API request mocking for login page and AuthAdapter
  • Used setupTests to set the values for environment variables in tests
  • Real email/password used in cypress test, unsure on this one.

Proof Of Work 📹

Tests pass

@netlify
Copy link

netlify bot commented Feb 16, 2023

Deploy Preview for moonlit-buttercream-05cb2f ready!

Name Link
🔨 Latest commit 71150ac
🔍 Latest deploy log https://app.netlify.com/sites/moonlit-buttercream-05cb2f/deploys/64080d54c348a400072105a0
😎 Deploy Preview https://deploy-preview-35--moonlit-buttercream-05cb2f.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@liamstevens111 liamstevens111 changed the base branch from develop to feature/7-login-page February 16, 2023 06:49
@github-actions
Copy link

github-actions bot commented Feb 16, 2023

@github-actions github-actions bot temporarily deployed to pull request February 16, 2023 06:50 Inactive
@liamstevens111 liamstevens111 changed the title Feature/21 backend login email password [#21] [Backend] As a user, I can login with an email and password Feb 16, 2023
@liamstevens111 liamstevens111 self-assigned this Feb 16, 2023
@liamstevens111 liamstevens111 added the feature New feature or request label Feb 16, 2023
@liamstevens111 liamstevens111 added this to the 0.1.0 milestone Feb 16, 2023
@github-actions github-actions bot temporarily deployed to pull request February 16, 2023 10:04 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 16, 2023 10:59 Inactive
@liamstevens111 liamstevens111 changed the title [#21] [Backend] As a user, I can login with an email and password [#21] [Backend] As a user, I can login with an email and password, [#8] [UI] As a user, I can login with an email and password Feb 17, 2023
@github-actions github-actions bot temporarily deployed to pull request February 17, 2023 08:34 Inactive
@liamstevens111 liamstevens111 force-pushed the feature/21-backend-login-email-password branch from fe714c3 to 8b55683 Compare February 17, 2023 08:36
@github-actions github-actions bot temporarily deployed to pull request February 17, 2023 08:37 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 17, 2023 11:32 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 18, 2023 19:51 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 20, 2023 03:43 Inactive
@liamstevens111 liamstevens111 force-pushed the feature/21-backend-login-email-password branch from 8f0e4e8 to 102e630 Compare February 21, 2023 08:27
@github-actions github-actions bot temporarily deployed to pull request February 21, 2023 08:33 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 22, 2023 05:06 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 22, 2023 08:25 Inactive
@liamstevens111 liamstevens111 added this to the 0.2.0 milestone Feb 24, 2023
Copy link
Collaborator

@hanam1ni hanam1ni left a comment

Choose a reason for hiding this comment

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

I get not found page when trying to access login path on preview site. Not sure, if I am doing something wrong 🤔
image


navigate('/');
} catch (error) {
let errorMessage = 'There was a problem receiving a response from the server';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add this base error message to the translation file?

Copy link
Owner Author

@liamstevens111 liamstevens111 Mar 1, 2023

Choose a reason for hiding this comment

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

Yup, forgot that one :)

Added here 61d68f0

return requestManager('GET', `${BaseAdapter.baseUrl}/${endpoint}`, params);
}

postRequest(endpoint: string, params: RequestParamsType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be request option to be more accurate with the request manager?

Suggested change
postRequest(endpoint: string, params: RequestParamsType) {
postRequest(endpoint: string, requestOption: RequestParamsType) {

Copy link
Owner Author

@liamstevens111 liamstevens111 Mar 1, 2023

Choose a reason for hiding this comment

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

I used the naming conventions from Compass so I think should be default, but I can go with this as well

edit: changed here 9d0540f 👍

@liamstevens111
Copy link
Owner Author

liamstevens111 commented Mar 1, 2023

I get not found page when trying to access login path on preview site. Not sure, if I am doing something wrong 🤔 image

@hanam1ni Yes, I noticed this too so I waited until merged to main to see. I think this will resolve the issue:

https://stackoverflow.com/questions/50752350/page-not-found-when-trying-to-access-a-site-deployed-on-netlify

Works now, I made following changes: 9538bf5. It involved creating a _redirects file.

Login page: https://63fedb58e0e03327cdf00509--moonlit-buttercream-05cb2f.netlify.app/login

Edit: Woops, login page doesn't send request correctly as client id and secret not in environment, or the URL. I added to netlify but not sure I need in workflow too, dont think so.

@github-actions github-actions bot temporarily deployed to pull request March 1, 2023 04:43 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 1, 2023 04:58 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 1, 2023 05:22 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 3, 2023 11:09 Inactive
@liamstevens111 liamstevens111 force-pushed the feature/21-backend-login-email-password branch from 2e47cf0 to fb04b03 Compare March 3, 2023 11:30
@github-actions github-actions bot temporarily deployed to pull request March 3, 2023 11:32 Inactive
@github-actions github-actions bot temporarily deployed to pull request March 7, 2023 03:45 Inactive
src/screens/Login/index.tsx Outdated Show resolved Hide resolved
<Input
name="email"
label={t('login.email')}
type="text"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't we use type="email" 🤔 or we want to use custom validation here?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yeah I didn't want the html5 default errors to appear on the page for the control (which I think is what would happen). What do you think? Is it not the preferred approach?

className="my-3 block h-14 w-80"
onInputChange={handleEmailChange}
/>
<div className="relative w-80">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we don't need w-80 as we already set the width of the password input itself 💭

Copy link
Owner Author

Choose a reason for hiding this comment

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

This comment and previous rectified here 👍

9929fd1

<>
<img className="inline-block" src={logo} alt="logo" />
<p data-test-id="login-header" className="my-8 text-white opacity-50">
{t('login.sign-in')} to Nimble
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we extract the whole text for translation? 🤔 (including to Nimble)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I answered that in a previous PR - #33 (comment)

My thinking was that Nimble is the company name and I don't think we should "translate" the company name? I think it would be the same in all languages? Let me know if you think otherwise :)

@github-actions github-actions bot temporarily deployed to pull request March 8, 2023 03:51 Inactive
@liamstevens111 liamstevens111 force-pushed the feature/21-backend-login-email-password branch from 398c3d8 to 5059f71 Compare March 8, 2023 04:17
@github-actions github-actions bot temporarily deployed to pull request March 8, 2023 04:19 Inactive
@liamstevens111 liamstevens111 force-pushed the feature/21-backend-login-email-password branch from 5059f71 to 71150ac Compare March 8, 2023 04:21
@github-actions github-actions bot temporarily deployed to pull request March 8, 2023 04:22 Inactive
@liamstevens111
Copy link
Owner Author

liamstevens111 commented Mar 8, 2023

I fixed cypress tests by adding environment variables to github workflow.

I added environment variables to Netlify but the preview is still showing "undefined" for URL during /login:

Screenshot 2023-03-08 at 11 24 44

Unsure at the moment, maybe I can address this in my other open PR #34. Is that OK?

cc @hanam1ni

@liamstevens111 liamstevens111 changed the title [#21] [Backend] As a user, I can login with an email and password, [#8] [UI] As a user, I can login with an email and password [#21] [#8] As a user, I can login with an email and password Mar 9, 2023
@liamstevens111 liamstevens111 requested a review from hanam1ni March 10, 2023 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.2.0 feature New feature or request
Projects
None yet
3 participants