Skip to content

Commit

Permalink
feature #12: Implement login
Browse files Browse the repository at this point in the history
  • Loading branch information
Boosmith committed Aug 29, 2019
1 parent 17189f2 commit a92c9f0
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 184 deletions.
346 changes: 173 additions & 173 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,175 +1,175 @@
{
"name": "trelloid",
"description": "Kanban board front end app.",
"main": "server.js",
"scripts": {
"start": "run-p start:dev start:api",
"start:dev": "REACT_APP_ENV=development node scripts/start.js",
"prestart:api": "node src/tools/createMockDb.js",
"start:api": "node src/tools/apiServer.js",
"test": "node scripts/test.js",
"build": "node scripts/build.js",
"postinstall": "REACT_APP_ENV=production node scripts/build.js"
},
"eslintConfig": {
"extends": "react-app"
},
"dependencies": {
"@babel/core": "7.5.5",
"@material-ui/core": "^4.3.3",
"@material-ui/icons": "^4.2.1",
"@svgr/webpack": "4.3.2",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"babel-eslint": "10.0.2",
"babel-jest": "^24.8.0",
"babel-loader": "8.0.6",
"babel-plugin-named-asset-import": "^0.3.3",
"babel-preset-react-app": "^9.0.1",
"bootstrap": "^4.3.1",
"bson": "^4.0.2",
"camelcase": "^5.2.0",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"css-loader": "2.1.1",
"dotenv": "6.2.0",
"dotenv-expand": "4.2.0",
"eslint-config-react-app": "^5.0.1",
"eslint-loader": "2.2.1",
"eslint-plugin-flowtype": "3.13.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "^1.6.1",
"express": "^4.17.1",
"file-loader": "3.0.1",
"fs-extra": "7.0.1",
"history": "^4.9.0",
"html-webpack-plugin": "4.0.0-beta.5",
"identity-obj-proxy": "3.0.0",
"immer": "^2.1.5",
"is-wsl": "^1.1.0",
"jest": "24.8.0",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "24.8.0",
"jest-watch-typeahead": "0.3.1",
"jquery": "^3.4.1",
"jsonwebtoken": "^8.5.1",
"mini-css-extract-plugin": "0.5.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.5.0",
"popper.js": "^1.15.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "7.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-app-polyfill": "^1.0.2",
"react-dev-utils": "^9.0.3",
"react-dom": "^16.9.0",
"react-html-parser": "^2.0.2",
"react-redux": "^6.0.1",
"react-router-dom": "^5.0.1",
"react-toastify": "^4.5.2",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"remarkable": "^2.0.0",
"reselect": "^4.0.0",
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"sass-loader": "7.2.0",
"semver": "6.3.0",
"style-loader": "1.0.0",
"terser-webpack-plugin": "1.4.1",
"ts-pnp": "1.1.2",
"typescript": "^3.5.3",
"url-loader": "2.1.0",
"webpack": "4.39.1",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.3.1"
},
"devDependencies": {
"bcrypt": "^3.0.6",
"cssnano": "^4.1.10",
"eslint": "^6.2.2",
"fetch-mock": "^7.3.9",
"json-server": "^0.14.2",
"node-fetch": "^2.3.0",
"npm-run-all": "^4.1.5",
"postcss-loader": "^3.0.0",
"random-words": "^1.1.0",
"redux-immutable-state-invariant": "^2.1.0",
"redux-mock-store": "^1.5.3",
"style-loader": "^0.23.1"
},
"engines": {
"node": ">=8"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
"name": "trelloid",
"description": "Kanban board front end app.",
"main": "server.js",
"scripts": {
"start": "run-p start:dev start:api",
"start:dev": "REACT_APP_ENV=development node --inspect scripts/start.js",
"prestart:api": "node src/tools/createMockDb.js",
"start:api": "node src/tools/apiServer.js",
"test": "node scripts/test.js",
"build": "node scripts/build.js",
"postinstall": "REACT_APP_ENV=production node scripts/build.js"
},
"eslintConfig": {
"extends": "react-app"
},
"dependencies": {
"@babel/core": "7.5.5",
"@material-ui/core": "^4.3.3",
"@material-ui/icons": "^4.2.1",
"@svgr/webpack": "4.3.2",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"babel-eslint": "10.0.2",
"babel-jest": "^24.8.0",
"babel-loader": "8.0.6",
"babel-plugin-named-asset-import": "^0.3.3",
"babel-preset-react-app": "^9.0.1",
"bootstrap": "^4.3.1",
"bson": "^4.0.2",
"camelcase": "^5.2.0",
"case-sensitive-paths-webpack-plugin": "2.2.0",
"css-loader": "2.1.1",
"dotenv": "6.2.0",
"dotenv-expand": "4.2.0",
"eslint-config-react-app": "^5.0.1",
"eslint-loader": "2.2.1",
"eslint-plugin-flowtype": "3.13.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.3",
"eslint-plugin-react-hooks": "^1.6.1",
"express": "^4.17.1",
"file-loader": "3.0.1",
"fs-extra": "7.0.1",
"history": "^4.9.0",
"html-webpack-plugin": "4.0.0-beta.5",
"identity-obj-proxy": "3.0.0",
"immer": "^2.1.5",
"is-wsl": "^1.1.0",
"jest": "24.8.0",
"jest-environment-jsdom-fourteen": "0.1.0",
"jest-resolve": "24.8.0",
"jest-watch-typeahead": "0.3.1",
"jquery": "^3.4.1",
"jsonwebtoken": "^8.5.1",
"mini-css-extract-plugin": "0.5.0",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pnp-webpack-plugin": "1.5.0",
"popper.js": "^1.15.0",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"postcss-normalize": "7.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "4.0.1",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-app-polyfill": "^1.0.2",
"react-dev-utils": "^9.0.3",
"react-dom": "^16.9.0",
"react-html-parser": "^2.0.2",
"react-redux": "^6.0.1",
"react-router-dom": "^5.0.1",
"react-toastify": "^4.5.2",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"remarkable": "^2.0.0",
"reselect": "^4.0.0",
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"sass-loader": "7.2.0",
"semver": "6.3.0",
"style-loader": "1.0.0",
"terser-webpack-plugin": "1.4.1",
"ts-pnp": "1.1.2",
"typescript": "^3.5.3",
"url-loader": "2.1.0",
"webpack": "4.39.1",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.3.1"
},
"devDependencies": {
"bcrypt": "^3.0.6",
"cssnano": "^4.1.10",
"eslint": "^6.2.2",
"fetch-mock": "^7.3.9",
"json-server": "^0.14.2",
"node-fetch": "^2.3.0",
"npm-run-all": "^4.1.5",
"postcss-loader": "^3.0.0",
"random-words": "^1.1.0",
"redux-immutable-state-invariant": "^2.1.0",
"redux-mock-store": "^1.5.3",
"style-loader": "^0.23.1"
},
"engines": {
"node": ">=8"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"roots": [
"<rootDir>/src"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
],
"testEnvironment": "jest-environment-jsdom-fourteen",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
],
"watchPlugins": [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname"
]
},
"babel": {
"presets": [
"react-app"
]
}
}
10 changes: 5 additions & 5 deletions src/api/authApi.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { handleResponse, handleError } from "./apiUtils";
const baseUrl = process.env.REACT_APP_API_URL + "/api/auth/";
const baseUrl = process.env.REACT_APP_API_URL + "/auth";

function login(username, password) {
function login(userName, password) {
const requestOptions = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password })
body: JSON.stringify({ userName, password })
};

return fetch(baseUrl + "/auth/login", requestOptions)
return fetch(baseUrl + "/login", requestOptions)
.then(handleResponse)
.then(token => {
localStorage.setItem("trelloid_token", JSON.stringify(token));
Expand All @@ -21,7 +21,7 @@ function logout() {
localStorage.removeItem("user");
}

export const auth = {
export default {
login,
logout
};
Loading

0 comments on commit a92c9f0

Please sign in to comment.