-
Notifications
You must be signed in to change notification settings - Fork 0
Login #13
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
base: master
Are you sure you want to change the base?
Conversation
| import fetchAsync from '../utils/fetch'; | ||
| import createExpiresCookie from '../utils/create-expires-cookie'; | ||
|
|
||
| const cookie = require('isomorphic-cookie'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://thumbs.gfycat.com/SmoggyHilariousBaiji-poster.jpg
Use import please
|
|
||
| const cookie = require('isomorphic-cookie'); | ||
|
|
||
| const minutesOfCookieLive = 60; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good approach to naming, but better English would be: minutesCookiesLive
| }; | ||
| } | ||
| export function loginSuccess(data) { | ||
| cookie.save('token', data.data.token, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use lodash/get for data.data.token so your code doesn't break when your server fails
| }; | ||
| } | ||
| export function alertCreator(text) { | ||
| const millisecondsToAlertDisapear = 3000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, better move this constant one level out
| dispatch(loginStart()); | ||
| try { | ||
| const payload = await fetchAsync(`${apiURL}/login`, 'POST', loginValue); | ||
| if (!payload.data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect you to check HTTP response status code... If you provide any on error
| }; | ||
| } | ||
| export function registrationSuccess(data) { | ||
| cookie.save('token', data.data.token, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use lodash/get for data.data.token so your code doesn't break when your server fails
| }; | ||
| } | ||
|
|
||
| export function registration(regitrationValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo (regitration)
| }; | ||
|
|
||
| function Login() { | ||
| const formLoginState = useSelector(state => state.form.Login); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if your form is suddenly null? Write useSelector(property('form.Login))` to avoid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same below
| @@ -0,0 +1,7 @@ | |||
| export default function createExpiresCookie(minutes) { | |||
| const millisecondsInSeconds = 1000; | |||
| const secondsInMinutes = 60; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these constants out
No description provided.