Skip to content

Commit

Permalink
Run new prettier config on branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lindboe committed May 11, 2023
1 parent 91f35fd commit fd40209
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 78 deletions.
14 changes: 10 additions & 4 deletions src/components/SignInButtons/Apple/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ function appleSignInRequest() {
responseType: appleAuthAndroid.ResponseType.ALL,
scope: appleAuthAndroid.Scope.ALL,
});
return appleAuthAndroid.signIn()
.then(response => response.id_token)
return appleAuthAndroid
.signIn()
.then((response) => response.id_token)
.catch((e) => {
Log.error('Request to sign in with Apple failed. Error: ', e);
throw e;
Expand All @@ -24,12 +25,17 @@ function appleSignInRequest() {
const AppleSignIn = () => {
const handleSignIn = () => {
appleSignInRequest()
.then(token => Session.beginAppleSignIn(token))
.then((token) => Session.beginAppleSignIn(token))
.catch((e) => {
Log.error('Apple authentication failed', e);
});
};
return <ButtonBase onPress={handleSignIn} icon={<AppleLogoIcon />} />;
return (
<ButtonBase
onPress={handleSignIn}
icon={<AppleLogoIcon />}
/>
);
};

AppleSignIn.displayName = 'AppleSignIn';
Expand Down
7 changes: 6 additions & 1 deletion src/components/SignInButtons/Apple/index.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ const AppleSignIn = () => {
const handleSignIn = () => {
// handlesignin
};
return <ButtonBase onPress={handleSignIn} icon={<AppleLogoIcon />} />;
return (
<ButtonBase
onPress={handleSignIn}
icon={<AppleLogoIcon />}
/>
);
};

AppleSignIn.displayName = 'AppleSignIn';
Expand Down
27 changes: 17 additions & 10 deletions src/components/SignInButtons/Apple/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,38 @@ import AppleLogoIcon from '../../../../assets/images/signIn/apple-logo.svg';
import * as Session from '../../../libs/actions/Session';

function appleSignInRequest() {
return appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
return appleAuth
.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,

// FULL_NAME must come first, see https://github.com/invertase/react-native-apple-authentication/issues/293
requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
})
.then(response => appleAuth.getCredentialStateForUser(response.user)
.then((credentialState) => {
// FULL_NAME must come first, see https://github.com/invertase/react-native-apple-authentication/issues/293
requestedScopes: [appleAuth.Scope.FULL_NAME, appleAuth.Scope.EMAIL],
})
.then((response) =>
appleAuth.getCredentialStateForUser(response.user).then((credentialState) => {
if (credentialState !== appleAuth.State.AUTHORIZED) {
Log.error('Authentication failed. Original response: ', response);
throw new Error('Authentication failed');
}
return response.identityToken;
}));
}),
);
}

const AppleSignIn = () => {
const handleSignIn = () => {
appleSignInRequest()
.then(token => Session.beginAppleSignIn(token))
.then((token) => Session.beginAppleSignIn(token))
.catch((e) => {
Log.error('Apple authentication failed', e);
});
};
return <ButtonBase onPress={handleSignIn} icon={<AppleLogoIcon />} />;
return (
<ButtonBase
onPress={handleSignIn}
icon={<AppleLogoIcon />}
/>
);
};

AppleSignIn.displayName = 'AppleSignIn';
Expand Down
5 changes: 3 additions & 2 deletions src/components/SignInButtons/Apple/index.website.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import APPLE_CONFIG from './AppleConfig';
const propTypes = {...withLocalizePropTypes};

const $appleButtonContainerStyle = {
width: 40, height: 40, marginRight: 20,
width: 40,
height: 40,
marginRight: 20,
};

const AppleSignIn = (props) => {
Expand Down Expand Up @@ -54,7 +56,6 @@ const AppleSignIn = (props) => {
data-type="sign in"
/>
</View>

);
};

Expand Down
5 changes: 4 additions & 1 deletion src/components/SignInButtons/ButtonBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ const style = {
};

const ButtonBase = ({onPress, icon}) => (
<Pressable onPress={onPress} style={style}>
<Pressable
onPress={onPress}
style={style}
>
{icon}
</Pressable>
);
Expand Down
122 changes: 67 additions & 55 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ function handleAppleAuthApiResponse(token) {
const {optimisticData, successData, failureData} = generateResponseData();
// eslint-disable-next-line rulesdir/no-api-side-effects-method
API.makeRequestWithSideEffects('AuthenticateApple', {token}, {optimisticData, successData, failureData})
.then(apiResponse => Log.info('API response: ', apiResponse))
.catch(apiError => Log.error('API Callback error: ', apiError));
.then((apiResponse) => Log.info('API response: ', apiResponse))
.catch((apiError) => Log.error('API Callback error: ', apiError));
}

/**
Expand Down Expand Up @@ -722,65 +722,77 @@ function authenticatePusher(socketID, channelName, callback) {
* Request a new validation link / magic code to unlink an unvalidated secondary login from a primary login
*/
function requestUnlinkValidationLink() {
const optimisticData = [{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: true,
errors: null,
message: null,
},
}];
const successData = [{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: Localize.translateLocal('unlinkLoginForm.linkSent'),
},
}];
const failureData = [{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
},
}];
const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: true,
errors: null,
message: null,
},
},
];
const successData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: Localize.translateLocal('unlinkLoginForm.linkSent'),
},
},
];
const failureData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
},
},
];

API.write('RequestUnlinkValidationLink', {email: credentials.login}, {optimisticData, successData, failureData});
}

function unlinkLogin(accountID, validateCode) {
const optimisticData = [{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
...CONST.DEFAULT_ACCOUNT_DATA,
isLoading: true,
},
}];
const successData = [{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: Localize.translateLocal('unlinkLoginForm.succesfullyUnlinkedLogin'),
const optimisticData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
...CONST.DEFAULT_ACCOUNT_DATA,
isLoading: true,
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.CREDENTIALS,
value: {
login: '',
},
}];
const failureData = [{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
},
}];
];
const successData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
message: Localize.translateLocal('unlinkLoginForm.succesfullyUnlinkedLogin'),
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.CREDENTIALS,
value: {
login: '',
},
},
];
const failureData = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ACCOUNT,
value: {
isLoading: false,
},
},
];

API.write('UnlinkLogin', {accountID, validateCode}, {optimisticData, successData, failureData});
}
Expand Down
11 changes: 6 additions & 5 deletions src/pages/signin/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ class LoginForm extends React.Component {
isAlertVisible={!_.isEmpty(serverErrorText)}
containerStyles={[styles.mh0]}
/>
<View style={{
flexDirection: 'row',
width: '100%',
justifyContent: 'center',
}}
<View
style={{
flexDirection: 'row',
width: '100%',
justifyContent: 'center',
}}
>
<AppleSignIn />
</View>
Expand Down

0 comments on commit fd40209

Please sign in to comment.