Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33321905
D14247.1768848164.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D14247.1768848164.diff
View Options
diff --git a/lib/components/secondary-device-qr-auth-context-provider.react.js b/lib/components/secondary-device-qr-auth-context-provider.react.js
--- a/lib/components/secondary-device-qr-auth-context-provider.react.js
+++ b/lib/components/secondary-device-qr-auth-context-provider.react.js
@@ -42,13 +42,15 @@
type SecondaryDeviceQRAuthContextType = {
+qrData: QRData,
- +generateQRCode: () => Promise<void>,
+ +openSecondaryQRAuth: () => Promise<void>,
+ +closeSecondaryQRAuth: () => void,
};
const SecondaryDeviceQRAuthContext: React.Context<?SecondaryDeviceQRAuthContextType> =
React.createContext<?SecondaryDeviceQRAuthContextType>({
qrData: null,
- generateQRCode: async () => {},
+ openSecondaryQRAuth: async () => {},
+ closeSecondaryQRAuth: () => {},
});
function SecondaryDeviceQRAuthContextProvider(props: Props): React.Node {
@@ -75,7 +77,7 @@
const identityContext = React.useContext(IdentityClientContext);
const identityClient = identityContext?.identityClient;
- const generateQRCode = React.useCallback(async () => {
+ const openSecondaryQRAuth = React.useCallback(async () => {
try {
const [ed25519, rawAESKey] = await Promise.all([
getContentSigningKey(),
@@ -91,6 +93,10 @@
}
}, [generateAESKey, setUnauthorizedDeviceID]);
+ const closeSecondaryQRAuth = React.useCallback(() => {
+ setUnauthorizedDeviceID(null);
+ }, [setUnauthorizedDeviceID]);
+
const logInSecondaryDevice = useSecondaryDeviceLogIn();
const performLogIn = React.useCallback(
async (userID: string) => {
@@ -98,10 +104,10 @@
await logInSecondaryDevice(userID);
} catch (err) {
onLogInError(err);
- void generateQRCode();
+ void openSecondaryQRAuth();
}
},
- [logInSecondaryDevice, onLogInError, generateQRCode],
+ [logInSecondaryDevice, onLogInError, openSecondaryQRAuth],
);
React.useEffect(() => {
@@ -212,9 +218,10 @@
const value = React.useMemo(
() => ({
qrData,
- generateQRCode,
+ openSecondaryQRAuth,
+ closeSecondaryQRAuth,
}),
- [qrData, generateQRCode],
+ [qrData, openSecondaryQRAuth, closeSecondaryQRAuth],
);
return (
diff --git a/native/account/qr-code-screen.react.js b/native/account/qr-code-screen.react.js
--- a/native/account/qr-code-screen.react.js
+++ b/native/account/qr-code-screen.react.js
@@ -1,5 +1,6 @@
// @flow
+import { useFocusEffect } from '@react-navigation/core';
import * as React from 'react';
import { View, Text, useWindowDimensions } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
@@ -25,11 +26,15 @@
};
function QRCodeScreen(props: QRCodeScreenProps): React.Node {
- const { qrData, generateQRCode } = useSecondaryDeviceQRAuthContext();
+ const { qrData, openSecondaryQRAuth, closeSecondaryQRAuth } =
+ useSecondaryDeviceQRAuthContext();
- React.useEffect(() => {
- void generateQRCode();
- }, [generateQRCode]);
+ useFocusEffect(
+ React.useCallback(() => {
+ void openSecondaryQRAuth();
+ return closeSecondaryQRAuth;
+ }, [closeSecondaryQRAuth, openSecondaryQRAuth]),
+ );
const { platform } = getConfig().platformDetails;
const qrCodeURL = React.useMemo(() => {
diff --git a/web/account/qr-code-login.react.js b/web/account/qr-code-login.react.js
--- a/web/account/qr-code-login.react.js
+++ b/web/account/qr-code-login.react.js
@@ -11,11 +11,13 @@
import css from './qr-code-login.css';
function QRCodeLogin(): React.Node {
- const { qrData, generateQRCode } = useSecondaryDeviceQRAuthContext();
+ const { qrData, openSecondaryQRAuth, closeSecondaryQRAuth } =
+ useSecondaryDeviceQRAuthContext();
React.useEffect(() => {
- void generateQRCode();
- }, [generateQRCode]);
+ void openSecondaryQRAuth();
+ return closeSecondaryQRAuth;
+ }, [closeSecondaryQRAuth, openSecondaryQRAuth]);
const { platform } = getConfig().platformDetails;
const qrCodeURL = React.useMemo(() => {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 6:42 PM (9 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5957758
Default Alt Text
D14247.1768848164.diff (3 KB)
Attached To
Mode
D14247: [native][web][lib] clean `unauthorizedDeviceID` after abandoning secondary device auth
Attached
Detach File
Event Timeline
Log In to Comment