-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebApp] Add Profile page google sso linking (#1085)
* profile page google sso linking * add error handling * fix comments * hide google sso behind variable
- Loading branch information
Showing
12 changed files
with
382 additions
and
71 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
87 changes: 87 additions & 0 deletions
87
packages/web-app/src/modules/account-views/account-views/components/GoogleSignInForm.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,87 @@ | ||
import classNames from 'classnames' | ||
import type { FunctionComponent } from 'react' | ||
import type { WithStyles } from 'react-jss' | ||
import withStyles from 'react-jss' | ||
import { config } from '../../../../config' | ||
import GoogleSigninDarkDisabled from './assets/GoogleSigninDarkDisabled.svg' | ||
import GoogleSigninDarkFocused from './assets/GoogleSigninDarkFocused.svg' | ||
import GoogleSigninDarkNormal from './assets/GoogleSigninDarkNormal.svg' | ||
import GoogleSigninDarkPressed from './assets/GoogleSigninDarkPressed.svg' | ||
|
||
const styles = { | ||
formContainer: { | ||
width: 191, | ||
height: 46, | ||
}, | ||
googleSigninButton: { | ||
padding: 0, | ||
margin: 0, | ||
border: 'none', | ||
width: '100%', | ||
height: '100%', | ||
background: 'transparent', | ||
backgroundRepeat: 'no-repeat', | ||
backgroundSize: 'cover', | ||
cursor: 'pointer', | ||
}, | ||
googleSigninButtonEnabled: { | ||
backgroundImage: `url(${GoogleSigninDarkNormal})`, | ||
|
||
'&:hover': { | ||
backgroundImage: `url(${GoogleSigninDarkFocused})`, | ||
}, | ||
'&:active': { | ||
backgroundImage: `url(${GoogleSigninDarkPressed})`, | ||
}, | ||
|
||
/*Preload google button images*/ | ||
'&::after': { | ||
position: 'absolute', | ||
width: 0, | ||
height: 0, | ||
overflow: 'hidden', | ||
zIndex: -1, | ||
content: `url(${GoogleSigninDarkNormal}) url(${GoogleSigninDarkDisabled}) url(${GoogleSigninDarkFocused}) url(${GoogleSigninDarkPressed})`, | ||
}, | ||
}, | ||
googleSigninButtonDisabled: { | ||
backgroundImage: `url(${GoogleSigninDarkDisabled})`, | ||
cursor: 'not-allowed', | ||
}, | ||
} | ||
|
||
export interface GoogleSignInFormProps extends WithStyles<typeof styles> { | ||
isTermsAndConditionsAccepted: boolean | ||
isTermsAndConditionsRequired: boolean | ||
} | ||
export const _GoogleSignInForm: FunctionComponent<GoogleSignInFormProps> = ({ | ||
classes, | ||
isTermsAndConditionsAccepted, | ||
isTermsAndConditionsRequired, | ||
}) => { | ||
const shouldEnableGoogleSignInButton = !isTermsAndConditionsRequired || isTermsAndConditionsAccepted | ||
const shouldDisableGoogleSignInButton = isTermsAndConditionsRequired && !isTermsAndConditionsAccepted | ||
|
||
return ( | ||
<form | ||
className={classes.formContainer} | ||
action={`${config.apiBaseUrl}/api/v2/authentication/external`} | ||
method="POST" | ||
> | ||
<input type="hidden" name="provider" value="google" /> | ||
{isTermsAndConditionsRequired && ( | ||
<input type="hidden" name="termsAccepted" value={`${isTermsAndConditionsAccepted}`} /> | ||
)} | ||
<button | ||
className={classNames(classes.googleSigninButton, { | ||
[classes.googleSigninButtonEnabled]: shouldEnableGoogleSignInButton, | ||
[classes.googleSigninButtonDisabled]: shouldDisableGoogleSignInButton, | ||
})} | ||
type="submit" | ||
disabled={shouldDisableGoogleSignInButton} | ||
/> | ||
</form> | ||
) | ||
} | ||
|
||
export const GoogleSignInForm = withStyles(styles)(_GoogleSignInForm) |
Oops, something went wrong.