Skip to content

Commit afa8296

Browse files
authored
Merge pull request #17 from riteshsangwan/improveLogin
Improve login
2 parents 90a9c9e + 232a26b commit afa8296

File tree

19 files changed

+587
-104
lines changed

19 files changed

+587
-104
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,27 @@ See Guild https://github.com/lorenwest/node-config/wiki/Configuration-Files
1818
|`PORT`| The port to listen|
1919
|`GOOGLE_API_KEY`| The google api key see (https://developers.google.com/maps/documentation/javascript/get-api-key#key)|
2020
|`API_BASE_URL`| The base URL for Drone API |
21-
21+
|`REACT_APP_AUTH0_CLIENT_ID`| The auth0 client id |
22+
|`REACT_APP_AUTH0_CLIENT_DOMAIN`| The auth0 client domain |
23+
24+
### Auth0 setup
25+
- Create an account on auth0.
26+
- Click on clients in left side menu, it will redirect you to client page. Click on CREATE CLIENT button
27+
to create a new client.
28+
- Copy the client id and client domain and export them as environment variables.
29+
- Add `http://localhost:3000` as Allowed callback url's in client settings.
30+
31+
### Add social connections
32+
33+
### Facebook social connection
34+
- To add facebook social connection to auth0, you have to create a facebook app.
35+
Go to facebook [developers](https://developers.facebook.com/apps) and create a new app.
36+
- Copy the app secret and app id to auth0 social connections facebook tab.
37+
- You have to setup the oauth2 callback in app oauth settings.
38+
- For more information visit auth0 [docs](https://auth0.com/docs/connections/social/facebook)
39+
40+
### Google social connection
41+
- For more information on how to connect google oauth2 client, visit official [docs](https://auth0.com/docs/connections/social/google)
2242

2343
## Install dependencies
2444
`npm i`

config/default.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/* eslint-disable import/no-commonjs */
22
/**
3-
* Main config file
3+
* Main config file for the server which is hosting the reat app
44
*/
55
module.exports = {
66
// below env variables are NOT visible in frontend
77
PORT: process.env.PORT || 3000,
88

99
// below env variables are visible in frontend
1010
GOOGLE_API_KEY: process.env.GOOGLE_API_KEY || 'AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI',
11-
API_BASE_PATH: process.env.API_BASE_PATH || 'https://kb-dsp-server-dev.herokuapp.com',
1211
};

envSample

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
REACT_APP_API_BASE_PATH=https://kb-dsp-server.herokuapp.com
2-
REACT_APP_SOCKET_URL=https://kb-dsp-server.herokuapp.com
3-
REACT_APP_AUTH0_CLIEND_ID=3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK
4-
REACT_APP_AUTH0_DOMAIN=dronetest.auth0.com
5-
REACT_APP_GOOGLE_API_KEY=AIzaSyCR3jfBdv9prCBYBOf-fPUDhjPP4K05YjE
1+
GOOGLE_API_KEY=AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI
2+
API_BASE_PATH=http://localhost:3500
3+
REACT_APP_AUTH0_CLIENT_ID=h7p6V93Shau3SSvqGrl6V4xrATlkrVGm
4+
REACT_APP_AUTH0_CLIENT_DOMAIN=spanhawk.auth0.com
5+
REACT_APP_SOCKET_URL=http://localhost:3500

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@
5555
"rc-tooltip": "^3.4.2",
5656
"react": "^15.3.2",
5757
"react-breadcrumbs": "^1.5.1",
58-
"react-count-down": "^1.0.3",
5958
"react-click-outside": "^2.2.0",
59+
"react-count-down": "^1.0.3",
6060
"react-css-modules": "^3.7.10",
6161
"react-date-picker": "^5.3.28",
6262
"react-dom": "^15.3.2",
63+
"react-dropdown": "^1.2.0",
6364
"react-flexbox-grid": "^0.10.2",
6465
"react-google-maps": "^6.0.1",
65-
"react-modal": "^1.5.2",
66-
"react-dropdown": "^1.2.0",
66+
"react-highcharts": "^11.0.0",
6767
"react-icheck": "^0.3.6",
6868
"react-input-range": "^0.9.3",
69-
"react-highcharts": "^11.0.0",
69+
"react-modal": "^1.5.2",
7070
"react-redux": "^4.0.0",
7171
"react-redux-toastr": "^4.2.2",
7272
"react-router": "^2.8.1",
@@ -75,8 +75,8 @@
7575
"react-simple-dropdown": "^1.1.5",
7676
"react-slick": "^0.14.5",
7777
"react-star-rating-component": "^1.2.2",
78-
"react-timeago": "^3.1.3",
7978
"react-tabs": "^0.8.2",
79+
"react-timeago": "^3.1.3",
8080
"reactable": "^0.14.1",
8181
"redbox-react": "^1.2.10",
8282
"redux": "^3.0.0",
@@ -86,8 +86,8 @@
8686
"redux-logger": "^2.6.1",
8787
"redux-thunk": "^2.0.0",
8888
"sass-loader": "^4.0.0",
89-
"socket.io-client": "^1.7.1",
9089
"slick-carousel": "^1.6.0",
90+
"socket.io-client": "^1.7.1",
9191
"style-loader": "^0.13.0",
9292
"superagent": "^2.3.0",
9393
"superagent-promise": "^1.1.0",

src/api/User.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ class UserApi {
5656
})});
5757
}
5858

59-
registerSocialUser(name, email) {
59+
registerSocialUser(name, email, token) {
6060
const url = `${this.basePath}/api/v1/login/social`;
6161

6262
return reqwest({
6363
url,
6464
method: 'post',
6565
type: 'json',
6666
contentType: 'application/json',
67+
headers: {
68+
Authorization: `Bearer ${token}`,
69+
},
6770
data: JSON.stringify({
6871
name,
6972
email,

src/components/TextField/TextField.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
width: 100%;
33
border: 1px solid #ebebeb;
44

5+
input[type="password"],
56
input[type="text"] {
67
width: 100%;
78
padding: 0 10px;

src/config/index.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1+
/* eslint-disable import/no-commonjs */
12
/**
2-
* Copyright (c) 2016 Topcoder Inc, All rights reserved.
3+
* Main config file for the react app
34
*/
4-
5-
/**
6-
* Webapp configuration
7-
*
8-
* @author TCSCODER
9-
* @version 1.0.0
10-
*/
11-
12-
const config = {
13-
api: {
14-
basePath: process.env.REACT_APP_API_BASE_PATH || 'http://localhost:3500',
15-
},
5+
module.exports = {
6+
// below env variables are visible in frontend
7+
API_BASE_PATH: process.env.API_BASE_PATH || 'http://localhost:3500',
8+
REACT_APP_AUTH0_CLIENT_ID: process.env.REACT_APP_AUTH0_CLIENT_ID || 'h7p6V93Shau3SSvqGrl6V4xrATlkrVGm',
9+
REACT_APP_AUTH0_CLIENT_DOMAIN: process.env.REACT_APP_AUTH0_CLIENT_DOMAIN || 'spanhawk.auth0.com',
10+
AUTH0_CALLBACK: 'http://localhost:3000',
1611
socket: {
1712
url: process.env.REACT_APP_SOCKET_URL || 'http://localhost:3500',
1813
},
19-
AUTH0_CLIEND_ID: process.env.REACT_APP_AUTH0_CLIEND_ID || '3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK',
20-
AUTH0_DOMAIN: process.env.REACT_APP_AUTH0_DOMAIN || 'dronetest.auth0.com',
2114
};
22-
23-
export default config;

src/routes/DronesMap/modules/DronesMap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {handleActions} from 'redux-actions';
22
import io from 'socket.io-client';
33
import APIService from 'services/APIService';
4-
import config from '../../../../config/default';
4+
import config from '../../../config';
55

66
// Drones will be updated and map will be redrawn every 3s
77
// Otherwise if drones are updated with high frequency (e.g. 0.5s), the map will be freezing
@@ -32,7 +32,7 @@ export const init = () => async(dispatch) => {
3232
const {body: {items: drones}} = await APIService.searchDrones({limit: DRONE_LIMIT});
3333
lastUpdated = new Date().getTime();
3434
dispatch({type: DRONES_LOADED, payload: {drones}});
35-
socket = io(config.API_BASE_PATH);
35+
socket = io(config.socket.url);
3636
socket.on('dronepositionupdate', (drone) => {
3737
pendingUpdates[drone.id] = drone;
3838
if (updateTimeoutId) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy