1
0
mirror of https://github.com/tooot-app/app synced 2025-01-31 10:44:58 +01:00

Added global scopes

This commit is contained in:
xmflsct 2023-01-09 16:54:30 +01:00
parent cd7e740ab1
commit be772f905d

View File

@ -67,10 +67,6 @@ const ComponentInstance: React.FC<Props> = ({
const appsMutation = useAppsMutation({ const appsMutation = useAppsMutation({
retry: false, retry: false,
onSuccess: async (data, variables) => { onSuccess: async (data, variables) => {
const scopes = featureCheck('deprecate_auth_follow')
? ['read', 'write', 'push']
: ['read', 'write', 'follow', 'push']
const clientId = data.client_id const clientId = data.client_id
const clientSecret = data.client_secret const clientSecret = data.client_secret
@ -79,19 +75,19 @@ const ComponentInstance: React.FC<Props> = ({
const request = new AuthSession.AuthRequest({ const request = new AuthSession.AuthRequest({
clientId, clientId,
clientSecret, clientSecret,
scopes, scopes: variables.scopes,
redirectUri redirectUri
}) })
await request.makeAuthUrlAsync(discovery) await request.makeAuthUrlAsync(discovery)
const promptResult = await request.promptAsync(discovery, await browserPackage()) const promptResult = await request.promptAsync(discovery, await browserPackage())
if (promptResult?.type === 'success') { if (promptResult.type === 'success') {
const { accessToken } = await AuthSession.exchangeCodeAsync( const { accessToken } = await AuthSession.exchangeCodeAsync(
{ {
clientId, clientId,
clientSecret, clientSecret,
scopes, scopes: variables.scopes,
redirectUri, redirectUri,
code: promptResult.params.code, code: promptResult.params.code,
extraParams: { extraParams: {
@ -195,6 +191,9 @@ const ComponentInstance: React.FC<Props> = ({
} }
}) })
const scopes = featureCheck('deprecate_auth_follow')
? ['read', 'write', 'push']
: ['read', 'write', 'follow', 'push']
const processUpdate = useCallback(() => { const processUpdate = useCallback(() => {
if (domain) { if (domain) {
const accounts = getGlobalStorage.object('accounts') const accounts = getGlobalStorage.object('accounts')
@ -209,12 +208,12 @@ const ComponentInstance: React.FC<Props> = ({
}, },
{ {
text: t('common:buttons.continue'), text: t('common:buttons.continue'),
onPress: () => appsMutation.mutate({ domain }) onPress: () => appsMutation.mutate({ domain, scopes })
} }
] ]
) )
} else { } else {
appsMutation.mutate({ domain }) appsMutation.mutate({ domain, scopes })
} }
} }
}, [domain]) }, [domain])