-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28372 from Expensify/nikki-saml-newdot-web
[SAML NewDot] Add SAML flow for web, mweb, desktop
- Loading branch information
Showing
15 changed files
with
336 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'underscore'; | ||
import styles from '../../styles/styles'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import Text from '../../components/Text'; | ||
import Button from '../../components/Button'; | ||
import * as Session from '../../libs/actions/Session'; | ||
import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink'; | ||
import Terms from './Terms'; | ||
import CONST from '../../CONST'; | ||
import ROUTES from '../../ROUTES'; | ||
import Navigation from '../../libs/Navigation/Navigation'; | ||
import * as ErrorUtils from '../../libs/ErrorUtils'; | ||
import useLocalize from '../../hooks/useLocalize'; | ||
import useNetwork from '../../hooks/useNetwork'; | ||
import useWindowDimensions from '../../hooks/useWindowDimensions'; | ||
import FormHelpMessage from '../../components/FormHelpMessage'; | ||
|
||
const propTypes = { | ||
/* Onyx Props */ | ||
|
||
/** The credentials of the logged in person */ | ||
credentials: PropTypes.shape({ | ||
/** The email/phone the user logged in with */ | ||
login: PropTypes.string, | ||
}), | ||
|
||
/** The details about the account that the user is signing in with */ | ||
account: PropTypes.shape({ | ||
/** Whether or not a sign on form is loading (being submitted) */ | ||
isLoading: PropTypes.bool, | ||
|
||
/** Form that is being loaded */ | ||
loadingForm: PropTypes.oneOf(_.values(CONST.FORMS)), | ||
|
||
/** Whether this account has 2FA enabled or not */ | ||
requiresTwoFactorAuth: PropTypes.bool, | ||
|
||
/** Server-side errors in the submitted authentication code */ | ||
errors: PropTypes.objectOf(PropTypes.string), | ||
}), | ||
|
||
/** Function that returns whether the user is using SAML or magic codes to log in */ | ||
setIsUsingMagicCode: PropTypes.func.isRequired, | ||
}; | ||
|
||
const defaultProps = { | ||
credentials: {}, | ||
account: {}, | ||
}; | ||
|
||
function ChooseSSOOrMagicCode({credentials, account, setIsUsingMagicCode}) { | ||
const {translate} = useLocalize(); | ||
const {isOffline} = useNetwork(); | ||
const {isSmallScreenWidth} = useWindowDimensions(); | ||
|
||
return ( | ||
<> | ||
<View> | ||
<Text style={[styles.loginHeroBody, styles.mb5, styles.textNormal, !isSmallScreenWidth ? styles.textAlignLeft : {}]}>{translate('samlSignIn.welcomeSAMLEnabled')}</Text> | ||
<Button | ||
isDisabled={isOffline} | ||
success | ||
style={[styles.mv3]} | ||
text={translate('samlSignIn.useSingleSignOn')} | ||
isLoading={account.isLoading} | ||
onPress={() => { | ||
Navigation.navigate(ROUTES.SAML_SIGN_IN); | ||
}} | ||
/> | ||
|
||
<View style={[styles.mt5]}> | ||
<Text style={[styles.loginHeroBody, styles.mb5, styles.textNormal, !isSmallScreenWidth ? styles.textAlignLeft : {}]}> | ||
{translate('samlSignIn.orContinueWithMagicCode')} | ||
</Text> | ||
</View> | ||
|
||
<Button | ||
isDisabled={isOffline} | ||
style={[styles.mv3]} | ||
text={translate('samlSignIn.useMagicCode')} | ||
isLoading={account.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM)} | ||
onPress={() => { | ||
Session.resendValidateCode(credentials.login); | ||
setIsUsingMagicCode(true); | ||
}} | ||
/> | ||
{Boolean(account) && !_.isEmpty(account.errors) && <FormHelpMessage message={ErrorUtils.getLatestErrorMessage(account)} />} | ||
<ChangeExpensifyLoginLink onPress={() => Session.clearSignInData()} /> | ||
</View> | ||
<View style={[styles.mt5, styles.signInPageWelcomeTextContainer]}> | ||
<Terms /> | ||
</View> | ||
</> | ||
); | ||
} | ||
|
||
ChooseSSOOrMagicCode.propTypes = propTypes; | ||
ChooseSSOOrMagicCode.defaultProps = defaultProps; | ||
ChooseSSOOrMagicCode.displayName = 'ChooseSSOOrMagicCode'; | ||
|
||
export default withOnyx({ | ||
credentials: {key: ONYXKEYS.CREDENTIALS}, | ||
account: {key: ONYXKEYS.ACCOUNT}, | ||
})(ChooseSSOOrMagicCode); |
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,66 @@ | ||
import React, {useEffect} from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import ONYXKEYS from '../../../ONYXKEYS'; | ||
import CONFIG from '../../../CONFIG'; | ||
import Icon from '../../../components/Icon'; | ||
import Text from '../../../components/Text'; | ||
import * as Expensicons from '../../../components/Icon/Expensicons'; | ||
import * as Illustrations from '../../../components/Icon/Illustrations'; | ||
import styles from '../../../styles/styles'; | ||
import themeColors from '../../../styles/themes/default'; | ||
import useLocalize from '../../../hooks/useLocalize'; | ||
|
||
const propTypes = { | ||
/** The credentials of the logged in person */ | ||
credentials: PropTypes.shape({ | ||
/** The email/phone the user logged in with */ | ||
login: PropTypes.string, | ||
}), | ||
}; | ||
|
||
const defaultProps = { | ||
credentials: {}, | ||
}; | ||
|
||
function SAMLSignInPage({credentials}) { | ||
const {translate} = useLocalize(); | ||
|
||
useEffect(() => { | ||
window.open(`${CONFIG.EXPENSIFY.SAML_URL}?email=${credentials.login}&referer=${CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER}`, '_self'); | ||
}, [credentials.login]); | ||
|
||
return ( | ||
<View style={styles.deeplinkWrapperContainer}> | ||
<View style={styles.deeplinkWrapperMessage}> | ||
<View style={styles.mb2}> | ||
<Icon | ||
width={200} | ||
height={164} | ||
src={Illustrations.RocketBlue} | ||
/> | ||
</View> | ||
<Text style={[styles.textHeadline, styles.textXXLarge, styles.textAlignCenter]}>{translate('samlSignIn.launching')}</Text> | ||
<View style={[styles.mt2, styles.mh2, styles.fontSizeNormal, styles.textAlignCenter]}> | ||
<Text style={[styles.textAlignCenter]}>{translate('samlSignIn.oneMoment')}</Text> | ||
</View> | ||
</View> | ||
<View style={styles.deeplinkWrapperFooter}> | ||
<Icon | ||
width={154} | ||
height={34} | ||
fill={themeColors.success} | ||
src={Expensicons.ExpensifyWordmark} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
SAMLSignInPage.propTypes = propTypes; | ||
SAMLSignInPage.defaultProps = defaultProps; | ||
|
||
export default withOnyx({ | ||
credentials: {key: ONYXKEYS.CREDENTIALS}, | ||
})(SAMLSignInPage); |
Oops, something went wrong.