Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ service/venv/lib/
service/venv/pip-selfcheck.json
service/venv/pyvenv.cfg
service/__pycache__/
*.pyc
21 changes: 16 additions & 5 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@
"bugs": {
"url": "https://github.com/appcell/ora-server/issues"
},
"homepage": "https://github.com/appcell/ora-server#readme",
"homepage": "http://owanalyzer.com",
"devDependencies": {
"react-scripts": "1.1.4",
"semantic-ui-css": "^2.3.3",
"semantic-ui-react": "^0.82.0"
"semantic-ui-react": "^0.82.3"
},
"dependencies": {
"react": "^16.4.0",
"react-dom": "^16.4.0"
"axios": "^0.18.0",
"connected-react-router": "^4.4.1",
"history": "^4.7.2",
"lodash": "^4.17.10",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0",
"semantic-ui-css": "^2.2.14"
},
"scripts": {
"start": "react-scripts start",
Expand Down
27 changes: 4 additions & 23 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,18 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>ORA Data Platform</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<form method="post" action="/" hidden="True">{{ form.csrf_token }}</form>
<script type="text/javascript">
window.csrf_token=document.getElementById("csrf_token").value
</script>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
28 changes: 0 additions & 28 deletions client/src/App.css

This file was deleted.

74 changes: 74 additions & 0 deletions client/src/actions/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import * as actionType from './types';
import axios from 'axios';
import _ from 'lodash';
import { URL, LOGIN, LOGOUT } from '../config/Api';

import { push } from 'connected-react-router'

export const setToken = (data) => {
return {
type: actionType.SET_TOKEN,
data
}
}

export const unsetToken = () => {
return {
type: actionType.UNSET_TOKEN
}
}

export function InvalidCredentialsException(message) {
this.message = message;
this.name = 'InvalidCredentialsException';
}

export function login(email, password, closeModal) {
return (dispatch, getState) => {
let csrf_token = window.csrf_token
if ( getState().login.authentication_token !== "" ){
dispatch(push('/route/home'))
closeModal()
} else {
return axios
.post(URL + LOGIN, {
email,
password,
csrf_token
})
.then(function (response) {
let data = {
...response.data.response.user,
email: email
}
dispatch(setToken(data));
dispatch(push('/route/home'))
closeModal()
})
.catch(function (error) {
// raise different exception if due to invalid credentials
if (_.get(error, 'response.status') === 400) {
throw new InvalidCredentialsException(error);
}
throw error;
});
}
}
}

export function logout() {
return (dispatch, getState) => {
return axios
.get(URL + LOGOUT)
.then(function (response) {
dispatch(unsetToken())
dispatch(push('/'))
})
.catch(function (error) {
// raise different exception if due to invalid credentials
if (_.get(error, 'response.status') === 400) {
console.log('logout error')
}
});
}
}
2 changes: 2 additions & 0 deletions client/src/actions/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const SET_TOKEN = "SET_TOKEN";
export const UNSET_TOKEN = "UNSET_TOKEN";
Loading