-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
367 changed files
with
5,447 additions
and
5,113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import styled from "@emotion/styled"; | ||
|
||
export const Divider = styled.div` | ||
border-top: 1px solid #ececec; | ||
`; |
25 changes: 25 additions & 0 deletions
25
packages/app-admin-cognito/src/components/FederatedProviders.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import styled from "@emotion/styled"; | ||
import { makeDecoratable } from "@webiny/app-admin"; | ||
|
||
const FlexContainer = styled.div` | ||
display: flex; | ||
column-gap: 10px; | ||
padding-top: 20px; | ||
justify-content: center; | ||
`; | ||
|
||
export interface ContainerProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Container = makeDecoratable( | ||
"FederatedProvidersContainer", | ||
({ children }: ContainerProps) => { | ||
return <FlexContainer>{children}</FlexContainer>; | ||
} | ||
); | ||
|
||
export const FederatedProviders = { | ||
Container | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from "react"; | ||
import { Logo, makeDecoratable } from "@webiny/app-admin"; | ||
import * as Styled from "./StyledComponents"; | ||
import { Elevation } from "@webiny/ui/Elevation"; | ||
import { Cell, Grid } from "@webiny/ui/Grid"; | ||
import { Typography } from "@webiny/ui/Typography"; | ||
|
||
export interface ContainerProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const Container = makeDecoratable("ViewContainer", ({ children }: ContainerProps) => ( | ||
<Styled.Wrapper> | ||
<Styled.LogoWrapper> | ||
<Logo /> | ||
</Styled.LogoWrapper> | ||
<Styled.LoginContent>{children}</Styled.LoginContent> | ||
</Styled.Wrapper> | ||
)); | ||
|
||
export interface ContentProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const Content = makeDecoratable("ViewContent", ({ children }: ContentProps) => ( | ||
<Elevation z={2}> | ||
<Styled.InnerContent>{children}</Styled.InnerContent> | ||
</Elevation> | ||
)); | ||
|
||
export interface FooterProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const Footer = makeDecoratable("ViewFooter", ({ children }: FooterProps) => { | ||
return ( | ||
<Grid> | ||
<Cell span={12} style={{ textAlign: "center" }}> | ||
{children} | ||
</Cell> | ||
</Grid> | ||
); | ||
}); | ||
|
||
export interface TitleProps { | ||
title: string; | ||
description?: React.ReactNode; | ||
} | ||
|
||
const Title = makeDecoratable("ViewTitle", ({ title, description }: TitleProps) => { | ||
return ( | ||
<Styled.Title> | ||
<h1> | ||
<Typography use="headline4">{title}</Typography> | ||
</h1> | ||
{description ? ( | ||
<p> | ||
<Typography use="body1">{description}</Typography> | ||
</p> | ||
) : null} | ||
</Styled.Title> | ||
); | ||
}); | ||
|
||
export const View = { | ||
Container, | ||
Logo, | ||
Content, | ||
Title, | ||
Footer | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/app-admin-cognito/src/federatedIdentityProviders.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react"; | ||
|
||
export const federatedIdentityProviders: Record<string, string> = { | ||
cognito: "COGNITO", | ||
google: "Google", | ||
facebook: "Facebook", | ||
amazon: "LoginWithAmazon", | ||
apple: "SignInWithApple" | ||
}; | ||
|
||
export interface SignInProps { | ||
signIn: () => void; | ||
} | ||
|
||
export type FederatedIdentityProvider = { | ||
name: string; | ||
component: React.FunctionComponent<SignInProps>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,37 @@ | ||
import React from "react"; | ||
import styled from "@emotion/styled"; | ||
import { Auth, CognitoHostedUIIdentityProvider } from "@aws-amplify/auth"; | ||
import { Auth } from "@aws-amplify/auth"; | ||
import { CognitoHostedUIIdentityProvider } from "@aws-amplify/auth/lib-esm/types/Auth"; | ||
import { | ||
FacebookLoginButton, | ||
GoogleLoginButton, | ||
AppleLoginButton, | ||
AmazonLoginButton | ||
} from "react-social-login-buttons"; | ||
import { CognitoFederatedProvider } from "~/index"; | ||
|
||
const federatedButtons = { | ||
Facebook: FacebookLoginButton, | ||
Google: GoogleLoginButton, | ||
Amazon: AmazonLoginButton, | ||
Apple: AppleLoginButton, | ||
Cognito: () => null | ||
}; | ||
|
||
const FederatedContainer = styled.div` | ||
border-top: 1px solid #ececec; | ||
padding-top: 20px; | ||
`; | ||
federatedIdentityProviders, | ||
FederatedIdentityProvider | ||
} from "~/federatedIdentityProviders"; | ||
import { FederatedProviders } from "~/components/FederatedProviders"; | ||
|
||
interface FederatedLoginProps { | ||
providers: CognitoFederatedProvider[]; | ||
providers: FederatedIdentityProvider[]; | ||
} | ||
|
||
export const FederatedLogin = ({ providers }: FederatedLoginProps) => { | ||
return ( | ||
<FederatedContainer> | ||
{providers.map(provider => { | ||
const Button = federatedButtons[provider]; | ||
<FederatedProviders.Container> | ||
{providers.map(({ name, component: Component }) => { | ||
const cognitoProviderName = federatedIdentityProviders[name] ?? name; | ||
const isCustomProvider = !(name in federatedIdentityProviders); | ||
|
||
const signIn = () => { | ||
if (isCustomProvider) { | ||
Auth.federatedSignIn({ | ||
customProvider: cognitoProviderName | ||
}); | ||
} else { | ||
Auth.federatedSignIn({ | ||
provider: cognitoProviderName as CognitoHostedUIIdentityProvider | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button | ||
key={provider} | ||
onClick={() => | ||
Auth.federatedSignIn({ | ||
provider: CognitoHostedUIIdentityProvider[provider] | ||
}) | ||
} | ||
/> | ||
); | ||
return <Component key={name} signIn={signIn} />; | ||
})} | ||
</FederatedContainer> | ||
</FederatedProviders.Container> | ||
); | ||
}; |
Oops, something went wrong.