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

Feat: Login UI Issue#14 #26

Merged
merged 2 commits into from
Jun 27, 2020

Conversation

mtreacy002
Copy link
Member

@mtreacy002 mtreacy002 commented Jun 20, 2020

Description

Add Login UI

Fixes #14 and #29

Type of Change:

  • Code
  • User Interface

Code/Quality Assurance Only

  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

  • running npm start and submit without input. Form validation required gave warning as expected.
  • login with existing user but with wrong password or username, error message is shown as expected.
  • login with correct credentials, user redirected to Member Portfolio page as expected.

link to Gif

giphy showing login screen

Note to tester/reviewer. To test this login ui you must run the backend server from the latest code change on login backend PR#60

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials

Code/Quality Assurance Only

  • My changes generate no new warnings

Additional Note
Up to User Interface only, backend API consumption is not yet added - wip

@mtreacy002 mtreacy002 self-assigned this Jun 20, 2020
@mtreacy002 mtreacy002 added Category: Coding Changes to code base or refactored code that doesn't fix a bug. Category: User Interface Improvements or additions to design. Program: GSOC Related to work completed during the Google Summer of Code Program. labels Jun 20, 2020
@mtreacy002 mtreacy002 added this to the GSoC: Coding Phase I milestone Jun 20, 2020
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers , Just pushed this Login form as user interface. Form validation required has been applied but backend API consumption is WIP.

@mtreacy002 mtreacy002 requested a review from a team June 22, 2020 02:21
@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers . This form now has error responses shown to user. I still need to workout how to persist the jwt token that got returned and carry that to the next page. @meenakshi-dhanani if you can give me some guidance in this, that'll be great. 😉

@mtreacy002 mtreacy002 force-pushed the issue14-login-ui branch 6 times, most recently from bea2e8f to 4913271 Compare June 23, 2020 08:54
@meenakshi-dhanani
Copy link
Contributor

Try and have more meaningful commit messages which indicate intent. eg. Allow a user to login.

src/Routes.js Outdated Show resolved Hide resolved

new FormData(e.target).forEach((value, key) => {
if (key === "username")
userInput[key] = value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need an if else statement here? The action that you are performing is the same either ways.
Why can't it simply be userInput[key] = value?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, fixed

type="text"
name="username"
placeholder="Username or Email"
onChange={e => setUsername(e.target.value)}
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no need to set here. You are fetching the values from FormData anyway. So even if you set here, it's not being used

Copy link
Member Author

Choose a reason for hiding this comment

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

done. remove onChange

@mtreacy002
Copy link
Member Author

Update @anitab-org/bridgeintech-maintainers and @meenakshi-dhanani . I've just pushed the changes requested in your review. Can you please re-review? Thanks

@mtreacy002
Copy link
Member Author

mtreacy002 commented Jun 25, 2020

Posted this in a wrong PR 🤣

update @anitab-org/bridgeintech-maintainers . Successful logged in user is now redirected to Member Portfolio page.

link to GIF

@mtreacy002
Copy link
Member Author

@meenakshi-dhanani and @anitab-org/bridgeintech-maintainers . I've pull rebased the latest merged to develop and fixed few things mentioned by Meena on the feedback;

  • changed switch to if else,
  • removed unused useState (access token and access expiry)
  • redo setting payload logic

PS: While I'm on it, I did the same in Register.js (changed setting up the payload logic and removed unused useState) for consistency.



export default function Login() {
const [errorMessage, setResponseMessage] = useState(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

errorMessage, setErrorMessage - try following the convention

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, missed that 😁

Copy link
Contributor

@meenakshi-dhanani meenakshi-dhanani left a comment

Choose a reason for hiding this comment

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

I have tested the following scenarios:

  • Redirect to My Space on successful login
  • Show error message when server is down
  • Show appropriate error for invalid credentials (401)

The unit tests for these also have passed. Approving!

@meenakshi-dhanani
Copy link
Contributor

@foongminwong could you test these? I've done a code review for Maya. I'm hoping you can add gifs and screenshots 😄

Copy link

@foongminwong foongminwong left a comment

Choose a reason for hiding this comment

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

The changes made in this PR were tested locally. Following are the results:

  1. Code review - Done by @meenakshi-dhanani

  2. All possible responses were tested as below (tap/zoom in to see clearer gifs):

Login API Login UI Expected Result Actual Result
bit-login-wrong-password bit-login-wrong-password-1 As a user, when I login with incorrect username/password, it should show an error.
bit-login-successful bit-login-successful-1 As a user, when I login with correct credentials, it should direct me to a BIT success landing page.
bit-login-user-pass-field-missing bit-login-user-pass-field-missing-1 As a user, if I leave one of the fields blank, it should prompt me to enter values for username/password.
bit-login-unverify-email bit-login-unverify-email-1 As a user, when I login with an unverified account, it should tell me verify my account first before logging in.
  1. Additional testcases covered: N/A

  2. Additional Comments:

  1. OS Version: Windows 10

@foongminwong foongminwong merged commit a1f4e39 into anitab-org:develop Jun 27, 2020
@mtreacy002
Copy link
Member Author

Wowww....That's an amazing tests report, @foongminwong. Thank youuu... 😍

@mtreacy002 mtreacy002 deleted the issue14-login-ui branch June 27, 2020 04:12
@mtreacy002 mtreacy002 changed the title WIP: Feat: Login UI Issue#14 Feat: Login UI Issue#14 Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Category: User Interface Improvements or additions to design. Program: GSOC Related to work completed during the Google Summer of Code Program.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login a user
3 participants