From 3eb96b5beda6a7403a98add72b60cc8da34cb2b9 Mon Sep 17 00:00:00 2001 From: Wahed Mangal Date: Mon, 8 Mar 2021 21:58:18 +0100 Subject: [PATCH] allow login with username/password for all dev/test branches --- amplify.yml | 23 +++++++++++++++++++++++ src/components/Login.tsx | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 amplify.yml diff --git a/amplify.yml b/amplify.yml new file mode 100644 index 00000000..36eb963f --- /dev/null +++ b/amplify.yml @@ -0,0 +1,23 @@ +version: 1 +backend: + phases: + build: + commands: + - '# Execute Amplify CLI with the helper script' + - amplifyPush --simple +frontend: + phases: + preBuild: + commands: + - npm ci + build: + commands: + - REACT_APP_USER_BRANCH=$USER_BRANCH + - npm run build + artifacts: + baseDirectory: build + files: + - '**/*' + cache: + paths: + - node_modules/**/* diff --git a/src/components/Login.tsx b/src/components/Login.tsx index 7c8d944b..07695ecd 100644 --- a/src/components/Login.tsx +++ b/src/components/Login.tsx @@ -1,5 +1,10 @@ +import React, { useState } from "react"; import { Button, makeStyles } from "@material-ui/core"; -import React from "react"; +import { + AmplifyAuthenticator, + AmplifySignIn, + AmplifySignUp, +} from "@aws-amplify/ui-react"; import { CognitoHostedUIIdentityProvider } from "@aws-amplify/auth/lib/types"; import { Auth } from "aws-amplify"; import { KnowitColors } from "../styles"; @@ -106,10 +111,31 @@ const loginStyle = makeStyles({ }, }); +const userBranch = process.env.REACT_APP_USER_BRANCH; +const isNotProd = userBranch !== "master"; const Login = (props: { isMobile: boolean }) => { + console.log("/tree/", userBranch, isNotProd); const style = loginStyle(); + const [showDevLogin, setShowDevLogin] = useState(false); - return ( + return showDevLogin ? ( + + + + + ) : (
@@ -143,6 +169,14 @@ const Login = (props: { isMobile: boolean }) => { > Logg inn + {isNotProd && ( + + )}