Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3249220
D6724.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6724.diff
View Options
diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js
--- a/web/account/log-in-form.react.js
+++ b/web/account/log-in-form.react.js
@@ -12,14 +12,25 @@
import TraditionalLoginForm from './traditional-login-form.react.js';
import OrBreak from '../components/or-break.react.js';
import { setPrimaryIdentityPublicKey } from '../redux/primary-identity-public-key-reducer.js';
+import { useSelector } from '../redux/redux-utils.js';
function LoginForm(): React.Node {
const { openConnectModal } = useConnectModal();
const { data: signer } = useSigner();
const dispatch = useDispatch();
+ const primaryIdentityPublicKey = useSelector(
+ state => state.primaryIdentityPublicKey,
+ );
+
React.useEffect(() => {
(async () => {
+ if (
+ primaryIdentityPublicKey !== null &&
+ primaryIdentityPublicKey !== undefined
+ ) {
+ return;
+ }
await olm.init();
const account = new olm.Account();
account.create();
@@ -29,7 +40,7 @@
payload: ed25519,
});
})();
- }, [dispatch]);
+ }, [dispatch, primaryIdentityPublicKey]);
const [
siweAuthFlowSelected,
diff --git a/web/account/traditional-login-form.react.js b/web/account/traditional-login-form.react.js
--- a/web/account/traditional-login-form.react.js
+++ b/web/account/traditional-login-form.react.js
@@ -37,6 +37,10 @@
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
+ const primaryIdentityPublicKey = useSelector(
+ state => state.primaryIdentityPublicKey,
+ );
+
const usernameInputRef = React.useRef();
React.useEffect(() => {
usernameInputRef.current?.focus();
@@ -63,11 +67,16 @@
const logInAction = React.useCallback(
async (extraInfo: LogInExtraInfo) => {
try {
+ invariant(
+ primaryIdentityPublicKey,
+ 'primaryIdentityPublicKey must be set in logInAction',
+ );
const result = await callLogIn({
...extraInfo,
username,
password,
logInActionSource: logInActionSources.logInFromWebForm,
+ primaryIdentityPublicKey,
});
modalContext.popModal();
return result;
@@ -83,7 +92,7 @@
throw e;
}
},
- [callLogIn, modalContext, password, username],
+ [callLogIn, modalContext, password, primaryIdentityPublicKey, username],
);
const onSubmit = React.useCallback(
@@ -158,7 +167,11 @@
<Button
variant="filled"
type="submit"
- disabled={inputDisabled}
+ disabled={
+ primaryIdentityPublicKey === null ||
+ primaryIdentityPublicKey === undefined ||
+ inputDisabled
+ }
onClick={onSubmit}
>
{loginButtonContent}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 12:46 PM (20 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2497910
Default Alt Text
D6724.diff (2 KB)
Attached To
Mode
D6724: [web] Include `primaryIdentityPublicKey` when logging in from `web`
Attached
Detach File
Event Timeline
Log In to Comment