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

#164046210: users can log in #13

Merged
merged 1 commit into from
Apr 17, 2019
Merged

Conversation

MandelaK
Copy link
Contributor

@MandelaK MandelaK commented Apr 8, 2019

What does this PR do?

Add login functionality to the application. When a user fills in the login form, they should get an appropriate response. Error messages are displayed in red and form validation is done when the form is submitted.

Description of task

Users should be able to log in so they can be identified and have a custom experience. When a user logs in, we store the token and dispatch an action to the redux store. A helper function is implemented to ensure that only valid tokens can be decoded.

The following are saved to localStorage when a user logs in:
- profileImage - Link to the user's profile image
- token - The user's token
- email - The user's email
- username - The username of the user

How has this been tested?

  • End-to-end testing
  • Unit tests

How can this be manually tested?

  • Clone this repo and checkout to the branch ft-users-login-#164046210
  • run npm install and create a .env file in your environment variables. Add the variable REACT_APP_BASE_URL to the env file and have it's value point to https://ah-legion-staging.herokuapp.com/api/ or your custom backend. Also add a REACT_APP_SECRET_KEY which should be the same as that on heroku.
  • Go to the login page and try logging in a user

Other information

  • I have implemented a function in the utils that checks whether a user is logged in by attempting to authenticate the token stored in the localStorage
  • Make sure you have run npm install and properly configure environment variables. Also restart your server and run source .env.
  • You can use axiosConfig to make API calls

PT

164046210

@MandelaK MandelaK added the Work In Progress The task/feature you were working on is not yet complete. Show the team where you are so far. label Apr 8, 2019
src/store/actions/authActions/LoginAction.jsx Outdated Show resolved Hide resolved
src/store/actions/authActions/LoginAction.js Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/utils/validation.js Show resolved Hide resolved
src/store/actions/authActions/LoginAction.js Outdated Show resolved Hide resolved
src/store/actions/authActions/LoginAction.js Outdated Show resolved Hide resolved
@abulojoshua1
Copy link
Contributor

@MandelaK, kindly rebase so as to add coveralls to your PR.

@MandelaK MandelaK force-pushed the ft-users-login-#164046210 branch 2 times, most recently from 8936f1d to 881938e Compare April 12, 2019 03:00
@MandelaK MandelaK force-pushed the ft-users-login-#164046210 branch 5 times, most recently from 21513f9 to ade0b36 Compare April 12, 2019 11:02
@MandelaK MandelaK marked this pull request as ready for review April 14, 2019 11:57
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/components/Header.jsx Show resolved Hide resolved
@MandelaK MandelaK added Completed You are done with what you were working on. Use to ask the team for reviews before a potential merge and removed Work In Progress The task/feature you were working on is not yet complete. Show the team where you are so far. labels Apr 15, 2019
@MandelaK MandelaK changed the title feat(login) users can log in #164046210: users can log in Apr 15, 2019
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Show resolved Hide resolved
src/index.jsx Show resolved Hide resolved
Copy link
Contributor

@RachelleMaina RachelleMaina left a comment

Choose a reason for hiding this comment

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

This looks good.

@cob04 cob04 self-requested a review April 16, 2019 11:48
Copy link
Contributor

@cob04 cob04 left a comment

Choose a reason for hiding this comment

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

Looks OK

Copy link
Contributor

@ElMonstro ElMonstro left a comment

Choose a reason for hiding this comment

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

Approved

src/store/reducers/index.js Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/tests/store/Actions/authActions/loginAction.test.js Outdated Show resolved Hide resolved
src/components/Header.jsx Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
@ElMonstro
Copy link
Contributor

Please fix the hound format @MandelaK

src/containers/LoginForm.jsx Show resolved Hide resolved
src/containers/LoginForm.jsx Show resolved Hide resolved
src/containers/LoginForm.jsx Show resolved Hide resolved
@MandelaK MandelaK force-pushed the ft-users-login-#164046210 branch 3 times, most recently from 4bbe1b0 to 86d68e0 Compare April 17, 2019 06:54
src/store/actions/authActions/LoginAction.js Outdated Show resolved Hide resolved
src/store/actions/authActions/LoginAction.js Outdated Show resolved Hide resolved
src/store/actions/authActions/LoginAction.js Outdated Show resolved Hide resolved
@MandelaK MandelaK force-pushed the ft-users-login-#164046210 branch 2 times, most recently from c0958ae to f16e68e Compare April 17, 2019 10:34
src/css/App.css Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
src/containers/LoginForm.jsx Outdated Show resolved Hide resolved
@MandelaK MandelaK force-pushed the ft-users-login-#164046210 branch 2 times, most recently from 1be081e to 1c1ff78 Compare April 17, 2019 12:30
@abulojoshua1
Copy link
Contributor

@MandelaK], kindly fix the merge conflicts.

- create login form
- users can log in
- errors are displayed above the specific input fields and input fields have a red border if they are not validated
- set up validation of input fields
- configure axios
- test loginReducer
- test login validator function
- tokens are stored in localStorage on successful login
- add function for validating authentication tokens
- add function for checking whether a user is logged in with valid jwt token
- users are redirected on successful login to the homepage
- logged in users cannot see the login form
- test login form
- add a spinner when a user is logging in
- store profile image, username and token when a user logs in
[starts #164046210]
[finishes #164046210]
Copy link
Contributor

@abulojoshua1 abulojoshua1 left a comment

Choose a reason for hiding this comment

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

LGTM

@abulojoshua1 abulojoshua1 merged commit 188fb19 into develop Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Completed You are done with what you were working on. Use to ask the team for reviews before a potential merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants