From ebe70b0e99fb39c16c8ffab04e312345a1cb47bc Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Mon, 2 Sep 2019 17:51:36 +0530 Subject: [PATCH 1/5] added redirects file --- app/client/public/_redirects | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/client/public/_redirects diff --git a/app/client/public/_redirects b/app/client/public/_redirects new file mode 100644 index 0000000000..e69de29bb2 From 4c2e44d3666d78640b9c723f1608512bce995faf Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Mon, 2 Sep 2019 17:57:55 +0530 Subject: [PATCH 2/5] minor fix --- app/client/public/_redirects | 1 + 1 file changed, 1 insertion(+) diff --git a/app/client/public/_redirects b/app/client/public/_redirects index e69de29bb2..293658da47 100644 --- a/app/client/public/_redirects +++ b/app/client/public/_redirects @@ -0,0 +1 @@ +/* /index.html \ No newline at end of file From 744e5b7043f52ed7fdcac16a68e21f603b80cd6d Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Mon, 2 Sep 2019 18:05:18 +0530 Subject: [PATCH 3/5] fixed redirect --- app/client/public/_redirects | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/public/_redirects b/app/client/public/_redirects index 293658da47..50a463356b 100644 --- a/app/client/public/_redirects +++ b/app/client/public/_redirects @@ -1 +1 @@ -/* /index.html \ No newline at end of file +/* /index.html 200 \ No newline at end of file From 588db871ee33f938fd331ff1468ac57a825fb545 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Mon, 2 Sep 2019 20:20:01 +0530 Subject: [PATCH 4/5] added protecrted routes and login page --- app/client/src/index.tsx | 7 ++++-- app/client/src/pages/common/LoginPage.tsx | 23 +++++++++++++++++++ .../src/pages/{ => common}/PageNotFound.tsx | 1 - .../src/pages/common/ProtectedRoute.tsx | 14 +++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 app/client/src/pages/common/LoginPage.tsx rename app/client/src/pages/{ => common}/PageNotFound.tsx (96%) create mode 100644 app/client/src/pages/common/ProtectedRoute.tsx diff --git a/app/client/src/index.tsx b/app/client/src/index.tsx index 5dcb9743f2..8312c6dfb8 100755 --- a/app/client/src/index.tsx +++ b/app/client/src/index.tsx @@ -4,7 +4,8 @@ import { Provider } from "react-redux"; import "./index.css"; import App from "./App"; import Editor from "./pages/Editor"; -import PageNotFound from "./pages/PageNotFound"; +import PageNotFound from "./pages/common/PageNotFound"; +import LoginPage from "./pages/common/LoginPage"; import * as serviceWorker from "./serviceWorker"; import { BrowserRouter, Route, Switch } from "react-router-dom"; import { createStore, applyMiddleware } from "redux"; @@ -14,6 +15,7 @@ import { ThemeProvider, theme } from "./constants/DefaultTheme"; import createSagaMiddleware from 'redux-saga' import { rootSaga } from "./sagas" import { appInitializer } from "./utils/AppsmithUtils"; +import ProtectedRoute from "./pages/common/ProtectedRoute"; appInitializer() WidgetBuilderRegistry.registerWidgetBuilders(); @@ -26,7 +28,8 @@ ReactDOM.render( - + + diff --git a/app/client/src/pages/common/LoginPage.tsx b/app/client/src/pages/common/LoginPage.tsx new file mode 100644 index 0000000000..ecfce186b0 --- /dev/null +++ b/app/client/src/pages/common/LoginPage.tsx @@ -0,0 +1,23 @@ +import * as React from "react" + +import { Card, Elevation } from "@blueprintjs/core" +import { RouterProps } from "react-router"; + +class LoginPage extends React.PureComponent { + + componentDidMount() { + let windowDoc: any = window + windowDoc.netlifyIdentity.open(); + } + + render() { + return ( +
+
+ ) + } +} + +export default LoginPage + + diff --git a/app/client/src/pages/PageNotFound.tsx b/app/client/src/pages/common/PageNotFound.tsx similarity index 96% rename from app/client/src/pages/PageNotFound.tsx rename to app/client/src/pages/common/PageNotFound.tsx index c7254cbf78..c42203e221 100644 --- a/app/client/src/pages/PageNotFound.tsx +++ b/app/client/src/pages/common/PageNotFound.tsx @@ -1,7 +1,6 @@ import * as React from "react" import { NonIdealState, Button, Card, Elevation } from "@blueprintjs/core" -import App from "../App"; import { RouterProps } from "react-router"; class PageNotFound extends React.PureComponent { diff --git a/app/client/src/pages/common/ProtectedRoute.tsx b/app/client/src/pages/common/ProtectedRoute.tsx new file mode 100644 index 0000000000..d2552bed75 --- /dev/null +++ b/app/client/src/pages/common/ProtectedRoute.tsx @@ -0,0 +1,14 @@ +import * as React from "react" +import _ from "lodash" +import { Route, Redirect } from "react-router-dom"; + +const ProtectedRoute = ({ path: path, component: Component, ...rest }: { path: string, component: React.ReactType }) => { + let windowDoc: any = window + return ( ( + !_.isNil(windowDoc.netlifyIdentity.currentUser()) + ? + : + )} />) +} + +export default ProtectedRoute \ No newline at end of file From ebe31f4acb6c3182fbe150816210b81a026787b2 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Mon, 2 Sep 2019 21:06:24 +0530 Subject: [PATCH 5/5] fixes for netlify user identity --- app/client/package.json | 1 + app/client/src/index.tsx | 3 +-- app/client/src/pages/common/LoginPage.tsx | 22 +++++++++---------- .../src/pages/common/ProtectedRoute.tsx | 4 +++- app/client/src/utils/AppsmithUtils.tsx | 2 ++ app/client/yarn.lock | 5 +++++ 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/client/package.json b/app/client/package.json index 7cb8c937af..c88739c1fb 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -28,6 +28,7 @@ "husky": "^1.3.1", "lint-staged": "^8.1.0", "lodash": "^4.17.11", + "netlify-identity-widget": "^1.5.5", "node-sass": "^4.11.0", "normalizr": "^3.3.0", "prettier": "^1.16.0", diff --git a/app/client/src/index.tsx b/app/client/src/index.tsx index 8312c6dfb8..89b4e5f52a 100755 --- a/app/client/src/index.tsx +++ b/app/client/src/index.tsx @@ -16,8 +16,7 @@ import createSagaMiddleware from 'redux-saga' import { rootSaga } from "./sagas" import { appInitializer } from "./utils/AppsmithUtils"; import ProtectedRoute from "./pages/common/ProtectedRoute"; - -appInitializer() +appInitializer(); WidgetBuilderRegistry.registerWidgetBuilders(); const sagaMiddleware = createSagaMiddleware() const store = createStore(appReducer, applyMiddleware(sagaMiddleware)); diff --git a/app/client/src/pages/common/LoginPage.tsx b/app/client/src/pages/common/LoginPage.tsx index ecfce186b0..f87a7b19ec 100644 --- a/app/client/src/pages/common/LoginPage.tsx +++ b/app/client/src/pages/common/LoginPage.tsx @@ -1,21 +1,19 @@ import * as React from "react" - -import { Card, Elevation } from "@blueprintjs/core" import { RouterProps } from "react-router"; +import netlifyIdentity from 'netlify-identity-widget'; class LoginPage extends React.PureComponent { - componentDidMount() { - let windowDoc: any = window - windowDoc.netlifyIdentity.open(); - } + componentDidMount() { + netlifyIdentity.open() + } - render() { - return ( -
-
- ) - } + render() { + return ( +
+
+ ) + } } export default LoginPage diff --git a/app/client/src/pages/common/ProtectedRoute.tsx b/app/client/src/pages/common/ProtectedRoute.tsx index d2552bed75..e0a050bef4 100644 --- a/app/client/src/pages/common/ProtectedRoute.tsx +++ b/app/client/src/pages/common/ProtectedRoute.tsx @@ -2,10 +2,12 @@ import * as React from "react" import _ from "lodash" import { Route, Redirect } from "react-router-dom"; +import netlifyIdentity from 'netlify-identity-widget'; + const ProtectedRoute = ({ path: path, component: Component, ...rest }: { path: string, component: React.ReactType }) => { let windowDoc: any = window return ( ( - !_.isNil(windowDoc.netlifyIdentity.currentUser()) + !_.isNil(netlifyIdentity.currentUser()) ? : )} />) diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index b57510cf7b..df044bf358 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -2,6 +2,7 @@ import { ReduxAction } from "../constants/ActionConstants" import { SENTRY_PROD_CONFIG, SENTRY_STAGE_CONFIG, HOTJAR_PROD_HJID, HOTJAR_PROD_HJSV } from "../constants/ThirdPartyConstants"; import * as Sentry from '@sentry/browser'; import AnalyticsUtil from "./AnalyticsUtil" +import netlifyIdentity from 'netlify-identity-widget'; export const createReducer = ( initialState: any, @@ -17,6 +18,7 @@ export const createReducer = ( } export const appInitializer = () => { + netlifyIdentity.init(); switch (process.env.REACT_APP_ENVIRONMENT) { case "PRODUCTION": Sentry.init(SENTRY_PROD_CONFIG); diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 6f4f816411..98f0f1de69 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -7305,6 +7305,11 @@ neo-async@^2.5.0, neo-async@^2.6.0, neo-async@^2.6.1: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== +netlify-identity-widget@^1.5.5: + version "1.5.5" + resolved "https://registry.yarnpkg.com/netlify-identity-widget/-/netlify-identity-widget-1.5.5.tgz#e9ba8d7676263507106060236cf55c2992f425e4" + integrity sha512-gCILbXMVn83TiRaiPCWk93ynyyYgxn8N/KoO+WOfyGZaNgq7gMMPtn7vo6VDe/ZczgyCn9DRlm3artNoj78/MQ== + next-tick@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"