Skip to content
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

Fix packages #48

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
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
84 changes: 79 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,82 @@
{
"extends": ["react-app", "plugin:prettier/recommended"],
"env": {
"browser": true,
"es6": true,
"jest": true
},
"extends": [
"airbnb"
],
"plugins": [
"jsx-a11y",
"prettier"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-console": "warn",
"prettier/prettier": "error",
"array-callback-return": "off"
"react/jsx-props-no-spreading": 0,
"react/state-in-constructor": 0,
"quotes": 0,
"array-callback-return": 0,
"arrow-parens": 0,
"react/destructuring-assignment": 0,
"no-tabs": 0,
"#N/A": 0,
"prettier/prettier": 0,
"react/jsx-filename-extension": 0,
"import/no-extraneous-dependencies": 0,
"camelcase": 0,
"react/no-access-state-in-setstate": 0,
"no-param-reassign": 0,
"react/no-unused-state": 0,
"no-mixed-spaces-and-tabs": 0,
"max-len": 0,
"react/no-unused-prop-types": 0,
"import/order": 0,
"no-use-before-define": 0,
"import/prefer-default-export": 0,
"consistent-return": 0,
"copy.js": 0,
"react/sort-comp": 0,
"no-unused-expressions": 0,
"eqeqeq": 0,
"no-empty": 0,
"no-nested-ternary": 0,
"prefer-destructuring": 0,
"import/no-named-as-default": 0,
"import/no-duplicates": 0,
"no-restricted-syntax": 0,
"no-plusplus": 0,
"react/default-props-match-prop-types": 0,
"no-continue": 0,
"no-underscore-dangle": 0,
"react/jsx-no-bind": 0,
"react/prefer-stateless-function": 0,
"react/jsx-closing-tag-location": 0,
"guard-for-in": 0,
"import/named": 0,
"jsx-a11y/no-noninteractive-element-interactions": 0,
"jsx-a11y/alt-text": 0,
"no-unreachable": 0,
"no-multi-assign": 0,
"default-case": 0,
"prefer-const": 0,
"import/no-mutable-exports": 0,
"jsx-a11y/click-events-have-key-events": 0
},
"settings": {
"import resolver": {
"node": {
"paths": [
"./client/src"
]
}
}
}
}
}
22 changes: 8 additions & 14 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import React, { Fragment } from "react";
import LandingPage from "./pages/LandingPage/LandingPage";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Alert from "./components/layout/alert";
import "bootstrap/dist/css/bootstrap.css";
import React from "react";
// Redux
import { Provider } from "react-redux";
import LandingPage from "./pages/LandingPage/LandingPage";
import "bootstrap/dist/css/bootstrap.css";
import store from "./store";

const App = () => {
return (
<Provider store={store}>
<Fragment>
<LandingPage />
</Fragment>
</Provider>
);
};
const App = () => (
<Provider store={store}>
<LandingPage />
</Provider>
);

export default App;
18 changes: 9 additions & 9 deletions client/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { Provider } from 'react-redux';
import App from './App';
import store from './store';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
div
);
ReactDOM.unmountComponentAtNode(div);
const div = document.createElement('div');
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
div,
);
ReactDOM.unmountComponentAtNode(div);
});
71 changes: 28 additions & 43 deletions client/src/Auth.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// src/Auth/Auth.js
/* eslint no-restricted-globals: */

import auth0 from "auth0-js";
//import jwtDecode from "jwt-decode";
import jwtDecode from "jwt-decode";
import { customAlert } from "./components/Confirm/Confirm";

// jwtDecode =require(jwt-decode);

let LOGIN_SUCCESS_PAGE = "/landingpage";
const LOGIN_SUCCESS_PAGE = "/landingpage";
const LOGIN_FAILURE_PAGE = "/";

export default class Auth {
Expand All @@ -16,55 +14,42 @@ export default class Auth {
redirectUri: "http://localhost:8080/callback",
audience: "https://demgamestest.auth0.com/api/v2/",
responseType: "token id_token",
scope: "openid profile email address"
scope: "openid profile email address",
});

// auth0 = new auth0.WebAuth({
// domain: 'pankaj-hashedin.auth0.com',
// clientID: '8APzGywrBbRrfx5BEx5iHFV6Zq3GWQai',
// redirectUri: 'http://localhost:8080/callback',
// audience:'https://pankaj-hashedin.auth0.com/api/v2/',
// responseType: 'token id_token',
// scope: 'openid profile email address'
// });

constructor() {
this.login = this.login.bind(this);
}

login() {
login = () => {
this.auth0.authorize({
prompt: "login"
prompt: "login",
});
}

setCohort(cohort) {
if(localStorage.getItem("cohort_address") !== "/landingpage") {
setCohort = (cohort) => {
if (localStorage.getItem("cohort_address") !== "/landingpage") {
localStorage.setItem("cohort_address", cohort);
}
}

getCohort(){
getCohort = () => {
if (localStorage.getItem("cohort_address")) {
return localStorage.getItem("cohort_address");
}
return null;
}

setStyle(style){
if(style !== null) {
setStyle = (style) => {
if (style !== null) {
localStorage.setItem("style", style);
}
}

getStyle(){
getStyle = () => {
if (localStorage.getItem("style")) {
return localStorage.getItem("style");
} else {
return "orange";
}
return "orange";
}

logout() {
logout = () => {
// Remove tokens and expiry time
localStorage.removeItem("access_token");
localStorage.removeItem("id_token");
Expand All @@ -80,45 +65,45 @@ export default class Auth {
connection: "demgamesDB",
email: null,
password: null,
username: null
username: null,
},
(err) => {
if (err) return customAlert(`Something went wrong: ${err.message}`);
return customAlert("success signup without login!");
},
function(err) {
if (err) return alert("Something went wrong: " + err.message);
return alert("success signup without login!");
}
);
}

handleAuthentication() {
this.auth0.parseHash((error, authResults) => {
if (authResults && authResults.accessToken && authResults.idToken) {
let expiresAt = JSON.stringify(
authResults.expiresIn * 1000 + new Date().getTime()
const expiresAt = JSON.stringify(
authResults.expiresIn * 1000 + new Date().getTime(),
);
localStorage.setItem("access_token", authResults.accessToken);
localStorage.setItem("id_token", authResults.idToken);
localStorage.setItem("expires_at", expiresAt);
location.hash = "";
location.pathname =localStorage.getItem("cohort_address") ? localStorage.getItem("cohort_address") : LOGIN_SUCCESS_PAGE;
location.pathname = localStorage.getItem("cohort_address") ? localStorage.getItem("cohort_address") : LOGIN_SUCCESS_PAGE;
} else if (error) {
location.pathname = LOGIN_FAILURE_PAGE;
console.log(error);
console.log(error); // eslint-disable-line
}
});
}

isAuthenticated() {
let expiresAt = JSON.parse(localStorage.getItem("expires_at"));
isAuthenticated = () => {
const expiresAt = JSON.parse(localStorage.getItem("expires_at"));
return new Date().getTime() < expiresAt;
}

getProfile() {
getProfile = () => {
if (localStorage.getItem("id_token")) {
return jwtDecode(localStorage.getItem("id_token"));
}
}

getAccessToken() {
getAccessToken = () => {
if (localStorage.getItem("access_token")) {
return localStorage.getItem("access_token");
}
Expand Down
16 changes: 8 additions & 8 deletions client/src/actions/alert.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import uuid from 'uuid';
import { v4 as uuid } from 'uuid';
import { SET_ALERT, REMOVE_ALERT } from './type';

export const setAlert = (msg, alertType) => dispatch => {
const id = uuid.v4();
dispatch({
type: SET_ALERT,
payload: { msg, alertType, id }
});
const id = uuid.v4();
dispatch({
type: SET_ALERT,
payload: { msg, alertType, id },
});

setTimeout(() => dispatch({ type: REMOVE_ALERT, payload: id }),5000);
}
setTimeout(() => dispatch({ type: REMOVE_ALERT, payload: id }), 5000);
};
2 changes: 1 addition & 1 deletion client/src/actions/type.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const SET_ALERT = 'SET_ALERT';
export const REMOVE_ALERT = 'REMOVE_ALERT';
export const REMOVE_ALERT = 'REMOVE_ALERT';
Loading