Skip to content

Commit

Permalink
Merge 3235ace into b6757d5
Browse files Browse the repository at this point in the history
  • Loading branch information
robisson committed Nov 10, 2018
2 parents b6757d5 + 3235ace commit cbea077
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 60 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "3.3.2",
"@material-ui/core": "3.4.0",
"@material-ui/icons": "3.0.1",
"axios": "0.18.0",
"bcrypt-nodejs": "0.0.3",
"body-parser": "1.18.3",
"cookie-parser": "1.4.3",
"cors": "2.8.4",
"cors": "2.8.5",
"csrf": "3.0.6",
"dotenv": "6.1.0",
"express": "4.16.4",
"immutability-helper": "2.8.1",
"jsonwebtoken": "8.3.0",
"mongoose": "5.3.8",
"mongoose": "5.3.10",
"multer": "1.4.1",
"prop-types": "15.6.2",
"react": "16.6.0",
"react-dnd": "5.0.0",
"react-dnd-html5-backend": "5.0.1",
"react-dom": "16.6.0",
"react": "16.6.1",
"react-dnd": "6.0.0",
"react-dnd-html5-backend": "6.0.0",
"react-dom": "16.6.1",
"react-jss": "8.6.1",
"react-redux": "5.1.0",
"react-router": "4.3.1",
Expand Down Expand Up @@ -50,8 +50,8 @@
"check": "npm-check"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.5",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.2",
Expand All @@ -63,7 +63,7 @@
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-env": "^7.1.5",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"apidoc": "0.17.6",
Expand All @@ -77,16 +77,16 @@
"coveralls": "3.0.2",
"cross-env": "5.2.0",
"enzyme": "3.7.0",
"enzyme-adapter-react-16": "1.6.0",
"enzyme-adapter-react-16": "1.7.0",
"enzyme-to-json": "3.3.4",
"eslint": "5.8.0",
"eslint": "5.9.0",
"eslint-plugin-flow-vars": "0.5.0",
"eslint-plugin-flowtype": "3.1.4",
"eslint-plugin-flowtype": "3.2.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "7.11.1",
"eslint-watch": "4.0.2",
"flow-bin": "0.85.0",
"flow-bin": "0.86.0",
"jest": "23.6.0",
"jest-localstorage-mock": "2.3.0",
"mocha": "5.2.0",
Expand All @@ -95,10 +95,10 @@
"npm-check": "5.9.0",
"npm-run-all": "4.1.3",
"nyc": "13.1.0",
"prettier": "1.14.3",
"prettier": "1.15.1",
"redux-devtools-extension": "2.13.5",
"redux-test-utils": "^0.3.0",
"webpack": "4.23.1",
"webpack": "4.25.1",
"webpack-bundle-analyzer": "3.0.3",
"webpack-cli": "3.1.2"
}
Expand Down
14 changes: 9 additions & 5 deletions src/client/actions/Login.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
// @flow
import actionsType from "./actionsType";
import BoardApi from "../api/UserApi";
import UserApi from "../api/UserApi";
import { type Dispatch } from "redux";

export function login(email: string, password: string): Function {
return (dispatch: Dispatch) => {
dispatch({ type: actionsType.LOADING_LOGIN });

return BoardApi.login(email, password)
return UserApi.login(email, password)
.then(({ data }) => {
let { success, message, token, user } = data;

if (!success) {
throw data;
}

if (success) {
localStorage.setItem("token", JSON.stringify(token));
localStorage.setItem("user", JSON.stringify(user));
}

dispatch(loginSuccess(success, message, user));
})
.catch(error => {
dispatch(loginError(false, error, {}));
.catch(({ success, message }) => {
dispatch(loginError(success, message, {}));
});
};
}

export function logout(): Function {
return (dispatch: Dispatch) => {
return BoardApi.logout().then(() => {
return UserApi.logout().then(() => {
localStorage.removeItem("token");
localStorage.removeItem("user");
localStorage.removeItem("state");
Expand Down
4 changes: 2 additions & 2 deletions src/client/api/UserApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class UserApi {
.then(response => {
return response;
})
.catch(error => {
return error;
.catch(({ response }) => {
return response;
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/components/Login/FormLogin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ describe("Login User", () => {
let expectedState = {
email: "email@example.com",
password: "mypassword",
requiredFields: false
emailFieldEmpty: false,
passwordFieldEmpty: false
};

//password field
Expand Down
46 changes: 45 additions & 1 deletion src/client/components/Login/__snapshots__/FormLogin.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,11 @@ exports[`Login User does not should call function onLogin when click button Logi
}
className="Login-text-4"
error={true}
helperText="The email field is empty"
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -140,14 +143,22 @@ exports[`Login User does not should call function onLogin when click button Logi
}
}
className="Login-text-4"
error={true}
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down Expand Up @@ -357,8 +368,11 @@ exports[`Login User should call function onLogin when click button Login with fi
}
className="Login-text-4"
error={false}
helperText=""
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -375,13 +389,21 @@ exports[`Login User should call function onLogin when click button Login with fi
}
className="Login-text-4"
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down Expand Up @@ -591,8 +613,11 @@ exports[`Login User should render 2 inputs and a Button 1`] = `
}
className="Login-text-4"
error={false}
helperText=""
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -609,13 +634,21 @@ exports[`Login User should render 2 inputs and a Button 1`] = `
}
className="Login-text-4"
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down Expand Up @@ -825,8 +858,11 @@ exports[`Login User should render 2 inputs and a Button 2`] = `
}
className="Login-text-4"
error={false}
helperText=""
inputRef={[Function]}
label="Type your email"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
variant="standard"
Expand All @@ -843,13 +879,21 @@ exports[`Login User should render 2 inputs and a Button 2`] = `
}
className="Login-text-4"
error={false}
helperText=""
label="Password"
onChange={[Function]}
onKeyUp={[Function]}
required={false}
select={false}
type="password"
variant="standard"
/>
<WithStyles(Typography)
align="center"
className="Login-textError-10"
gutterBottom={true}
variant="subtitle2"
/>
<div
style={
Object {
Expand Down

0 comments on commit cbea077

Please sign in to comment.