Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
allow login with username/password for all dev/test branches
Browse files Browse the repository at this point in the history
  • Loading branch information
awgaan committed Mar 9, 2021
1 parent 6ea3e10 commit 3eb96b5
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
23 changes: 23 additions & 0 deletions amplify.yml
Original file line number Diff line number Diff line change
@@ -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/**/*
38 changes: 36 additions & 2 deletions src/components/Login.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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<boolean>(false);

return (
return showDevLogin ? (
<AmplifyAuthenticator usernameAlias="email">
<AmplifySignIn
headerText="Username/password login for developers"
slot="sign-in"
usernameAlias="email"
/>
<AmplifySignUp
slot="sign-up"
usernameAlias="email"
formFields={[
{ type: "name", label: "Name" },
{ type: "password" },
{ type: "email" },
]}
/>
</AmplifyAuthenticator>
) : (
<div className={style.container}>
<div className={style.topDiv} />
<div className={style.midDiv} />
Expand Down Expand Up @@ -143,6 +169,14 @@ const Login = (props: { isMobile: boolean }) => {
>
Logg inn
</Button>
{isNotProd && (
<Button
className={style.loginButton}
onClick={() => setShowDevLogin(true)}
>
Dev login
</Button>
)}
</div>
</div>
</div>
Expand Down

0 comments on commit 3eb96b5

Please sign in to comment.