Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Feat/16 authentication #33

Merged
merged 6 commits into from
Feb 22, 2019
Merged

Feat/16 authentication #33

merged 6 commits into from
Feb 22, 2019

Conversation

CamiloGarciaLaRotta
Copy link
Contributor

Description

  • Advances Implement error handling for all forms #10 by implementing error handling of the login form
  • Login is now a reducer component.
    It performs the authentication and via a callback returns the JWT to the App component.
  • Services has a side-effect method "authenticate" which POSTs the credentials to the Auth backend.
    If the login is succesful, it returns the JWT to Login.
    If the login fails, it changes the state of Login to DisplayError
  • Services has a new type "authResponse" to decode the HTTP response
  • valueFromEvent was refactored to Services because its used in multiple components
  • Changed the Sign in with Google dummy button for Sign Up,
    which redirects the user to the web-app sign up page
    (when it will be available online)

Closes #16

Checklist

  • Code compiles correctly
  • All tests passing
  • There is an open issue linked to this PR
  • Created tests which fail without the change (if possible)
  • Extended the README / documentation (if necessary)

@CamiloGarciaLaRotta CamiloGarciaLaRotta added the enhancement New feature or request label Feb 16, 2019
@CamiloGarciaLaRotta CamiloGarciaLaRotta added this to the Deliverable 1 milestone Feb 16, 2019
@CamiloGarciaLaRotta CamiloGarciaLaRotta self-assigned this Feb 16, 2019
@coveralls
Copy link

coveralls commented Feb 16, 2019

Coverage Status

Coverage decreased (-7.6%) to 30.45% when pulling d1b4992 on feat/16-auth into 2a9d46d on master.

@CamiloGarciaLaRotta
Copy link
Contributor Author

Travis failed because Coveralls hasn't created a record for the branch.
Probably because we have the free version we get super shitty service.
It took the last branch 1h to create the record.

Copy link
Contributor

@alexboii alexboii left a comment

Choose a reason for hiding this comment

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

looks okay, as long as it works

the only thing that's really needed here is that you ought to store the jwt in local storage and load it before the HOC mounts, check what the guy does here: https://github.com/jchavarri/chrome-extension-starter-reason-react/blob/master/src/colorSelector.re

there are bindings for it too

@@ -10,8 +10,7 @@
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"storage"
Copy link
Contributor

Choose a reason for hiding this comment

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

why was storage removed? are you not storing the jwt in localstorage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thats beyond the scope of hooking the extension to the auth API (#16)
The storage of the JWT is in the scope of #19
I can make a PR after for with that enhancement

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah but wouldn't I have to login every time I click on the chrome extension? the two tasks are hand-in-hand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, you currently will have to login every time you click on the extension.
this PR only addresses login in and out for the Login components perspective.
#19 handles login in and out from a broader perspective.

this PR ensures that first step is functional in order to work on the next PRs (#17 #19)

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 vote against holding up the PR until #19 is done.
storing the JWT in storage has nothing to do with the Login component and its call to the Auth API

@@ -1,13 +1,5 @@
open Chrome.Extensions;

/** Convert value from event to string
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this moved from here to services? if anything, it needs to be under a new "utilities.re" file

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 can move it there, in the PR description I said it was extracted because its used across multiple components

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in latest commit

src/App.re Outdated
| JobApp;

type state = {route};
type state = {token: string};
Copy link
Contributor

Choose a reason for hiding this comment

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

Option(string) should be used here, but at this point I don't care

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in latest commit

@CamiloGarciaLaRotta
Copy link
Contributor Author

for reference, many people are experiencing the same Coveralls failure: Coveralls GitHub Issue

Copy link
Contributor

@alexboii alexboii left a comment

Choose a reason for hiding this comment

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

I still think that the jwt storage & login should be the same PR

for then testing the next part (adding job applications) would become a nightmare

if you want I can approve this but I say we wait for #19 before merging

@@ -10,8 +10,7 @@
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"storage"
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah but wouldn't I have to login every time I click on the chrome extension? the two tasks are hand-in-hand

- Advances #10 by implementing error handling of the login form
- Login is now a reducer component. It performs the authentication
  and via a callback returns the JWT to the App component.
- Services has a side-effect method "authenticate" which POSTs the
  credentials to the Auth backend.
  If the login is succesful, it returns the JWT to Login
  If the login fails, it changes the state of Login to DisplayError
- Services has a new type "authResponse" to decode the HTTP response
- valueFromEvent was refactored to Services because its used in
  multiple components

Closes #16
@CamiloGarciaLaRotta CamiloGarciaLaRotta merged commit c0c5781 into master Feb 22, 2019
@CamiloGarciaLaRotta CamiloGarciaLaRotta deleted the feat/16-auth branch February 22, 2019 18:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants