@@ -2,7 +2,7 @@ import { WebApplication } from '@/ui_models/application';
|
|||||||
import { AppState } from '@/ui_models/app_state';
|
import { AppState } from '@/ui_models/app_state';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { FunctionComponent } from 'preact';
|
import { FunctionComponent } from 'preact';
|
||||||
import { useState } from 'preact/hooks';
|
import { useEffect, useState } from 'preact/hooks';
|
||||||
import { Checkbox } from '../Checkbox';
|
import { Checkbox } from '../Checkbox';
|
||||||
import { Icon } from '../Icon';
|
import { Icon } from '../Icon';
|
||||||
import { InputWithIcon } from '../InputWithIcon';
|
import { InputWithIcon } from '../InputWithIcon';
|
||||||
@@ -11,14 +11,70 @@ type Props = {
|
|||||||
application: WebApplication;
|
application: WebApplication;
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
onVaultChange?: (isVault: boolean, vaultedEmail?: string) => void;
|
||||||
|
onStrictSignInChange?: (isStrictSignIn: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AdvancedOptions: FunctionComponent<Props> = observer(
|
export const AdvancedOptions: FunctionComponent<Props> = observer(
|
||||||
({ appState, application, disabled = false, children }) => {
|
({
|
||||||
|
appState,
|
||||||
|
application,
|
||||||
|
disabled = false,
|
||||||
|
onVaultChange,
|
||||||
|
onStrictSignInChange,
|
||||||
|
children,
|
||||||
|
}) => {
|
||||||
const { server, setServer, enableServerOption, setEnableServerOption } =
|
const { server, setServer, enableServerOption, setEnableServerOption } =
|
||||||
appState.accountMenu;
|
appState.accountMenu;
|
||||||
const [showAdvanced, setShowAdvanced] = useState(false);
|
const [showAdvanced, setShowAdvanced] = useState(false);
|
||||||
|
|
||||||
|
const [isVault, setIsVault] = useState(false);
|
||||||
|
const [vaultName, setVaultName] = useState('');
|
||||||
|
const [vaultUserphrase, setVaultUserphrase] = useState('');
|
||||||
|
|
||||||
|
const [isStrictSignin, setIsStrictSignin] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const recomputeVaultedEmail = async () => {
|
||||||
|
const vaultedEmail = await application.vaultToEmail(
|
||||||
|
vaultName,
|
||||||
|
vaultUserphrase
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!vaultedEmail) {
|
||||||
|
if (vaultName?.length > 0 && vaultUserphrase?.length > 0) {
|
||||||
|
application.alertService.alert('Unable to compute vault name.');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onVaultChange?.(true, vaultedEmail);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (vaultName && vaultUserphrase) {
|
||||||
|
recomputeVaultedEmail();
|
||||||
|
}
|
||||||
|
}, [vaultName, vaultUserphrase, application, onVaultChange]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onVaultChange?.(isVault);
|
||||||
|
}, [isVault, onVaultChange]);
|
||||||
|
|
||||||
|
const handleIsVaultChange = () => {
|
||||||
|
setIsVault(!isVault);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVaultNameChange = (e: Event) => {
|
||||||
|
if (e.target instanceof HTMLInputElement) {
|
||||||
|
setVaultName(e.target.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVaultUserphraseChange = (e: Event) => {
|
||||||
|
if (e.target instanceof HTMLInputElement) {
|
||||||
|
setVaultUserphrase(e.target.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleServerOptionChange = (e: Event) => {
|
const handleServerOptionChange = (e: Event) => {
|
||||||
if (e.target instanceof HTMLInputElement) {
|
if (e.target instanceof HTMLInputElement) {
|
||||||
setEnableServerOption(e.target.checked);
|
setEnableServerOption(e.target.checked);
|
||||||
@@ -32,6 +88,12 @@ export const AdvancedOptions: FunctionComponent<Props> = observer(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleStrictSigninChange = () => {
|
||||||
|
const newValue = !isStrictSignin;
|
||||||
|
setIsStrictSignin(newValue);
|
||||||
|
onStrictSignInChange?.(newValue);
|
||||||
|
};
|
||||||
|
|
||||||
const toggleShowAdvanced = () => {
|
const toggleShowAdvanced = () => {
|
||||||
setShowAdvanced(!showAdvanced);
|
setShowAdvanced(!showAdvanced);
|
||||||
};
|
};
|
||||||
@@ -50,6 +112,70 @@ export const AdvancedOptions: FunctionComponent<Props> = observer(
|
|||||||
{showAdvanced ? (
|
{showAdvanced ? (
|
||||||
<div className="px-3 my-2">
|
<div className="px-3 my-2">
|
||||||
{children}
|
{children}
|
||||||
|
|
||||||
|
{appState.enableUnfinishedFeatures && (
|
||||||
|
<div className="flex justify-between items-center mb-1">
|
||||||
|
<Checkbox
|
||||||
|
name="vault-mode"
|
||||||
|
label="Vault Mode"
|
||||||
|
checked={isVault}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={handleIsVaultChange}
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
href="https://standardnotes.com/help/80"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
title="Learn more"
|
||||||
|
>
|
||||||
|
<Icon type="info" className="color-neutral" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{appState.enableUnfinishedFeatures && isVault && (
|
||||||
|
<>
|
||||||
|
<InputWithIcon
|
||||||
|
className={`mb-2`}
|
||||||
|
icon="folder"
|
||||||
|
inputType="text"
|
||||||
|
placeholder="Vault name"
|
||||||
|
value={vaultName}
|
||||||
|
onChange={handleVaultNameChange}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
<InputWithIcon
|
||||||
|
className={`mb-2 `}
|
||||||
|
icon="server"
|
||||||
|
inputType={'text'}
|
||||||
|
placeholder="Vault userphrase"
|
||||||
|
value={vaultUserphrase}
|
||||||
|
onChange={handleVaultUserphraseChange}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{onStrictSignInChange && (
|
||||||
|
<div className="flex justify-between items-center mb-1">
|
||||||
|
<Checkbox
|
||||||
|
name="use-strict-signin"
|
||||||
|
label="Use strict sign-in"
|
||||||
|
checked={isStrictSignin}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={handleStrictSigninChange}
|
||||||
|
/>
|
||||||
|
<a
|
||||||
|
href="https://standardnotes.com/help/security"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
title="Learn more"
|
||||||
|
>
|
||||||
|
<Icon type="info" className="color-neutral" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<Checkbox
|
<Checkbox
|
||||||
name="custom-sync-server"
|
name="custom-sync-server"
|
||||||
label="Custom sync server"
|
label="Custom sync server"
|
||||||
|
|||||||
@@ -162,12 +162,6 @@ export const ConfirmPassword: FunctionComponent<Props> = observer(
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</form>
|
</form>
|
||||||
<div className="h-1px my-2 bg-border"></div>
|
|
||||||
<AdvancedOptions
|
|
||||||
appState={appState}
|
|
||||||
application={application}
|
|
||||||
disabled={isRegistering}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export const CreateAccount: FunctionComponent<Props> = observer(
|
|||||||
|
|
||||||
const emailInputRef = useRef<HTMLInputElement>(null);
|
const emailInputRef = useRef<HTMLInputElement>(null);
|
||||||
const passwordInputRef = useRef<HTMLInputElement>(null);
|
const passwordInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const [isVault, setIsVault] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (emailInputRef.current) {
|
if (emailInputRef.current) {
|
||||||
@@ -82,6 +83,13 @@ export const CreateAccount: FunctionComponent<Props> = observer(
|
|||||||
setPassword('');
|
setPassword('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onVaultChange = (isVault: boolean, vaultedEmail?: string) => {
|
||||||
|
setIsVault(isVault);
|
||||||
|
if (isVault && vaultedEmail) {
|
||||||
|
setEmail(vaultedEmail);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center px-3 mt-1 mb-3">
|
<div className="flex items-center px-3 mt-1 mb-3">
|
||||||
@@ -101,6 +109,7 @@ export const CreateAccount: FunctionComponent<Props> = observer(
|
|||||||
inputType="email"
|
inputType="email"
|
||||||
placeholder="Email"
|
placeholder="Email"
|
||||||
value={email}
|
value={email}
|
||||||
|
disabled={isVault}
|
||||||
onChange={handleEmailChange}
|
onChange={handleEmailChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
ref={emailInputRef}
|
ref={emailInputRef}
|
||||||
@@ -130,7 +139,11 @@ export const CreateAccount: FunctionComponent<Props> = observer(
|
|||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
<div className="h-1px my-2 bg-border"></div>
|
<div className="h-1px my-2 bg-border"></div>
|
||||||
<AdvancedOptions application={application} appState={appState} />
|
<AdvancedOptions
|
||||||
|
application={application}
|
||||||
|
appState={appState}
|
||||||
|
onVaultChange={onVaultChange}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const GeneralAccountMenu: FunctionComponent<Props> = observer(
|
|||||||
<>
|
<>
|
||||||
<div className="px-3 mb-3 color-foreground text-sm">
|
<div className="px-3 mb-3 color-foreground text-sm">
|
||||||
<div>You're signed in as:</div>
|
<div>You're signed in as:</div>
|
||||||
<div className="my-0.5 font-bold">{user.email}</div>
|
<div className="my-0.5 font-bold wrap">{user.email}</div>
|
||||||
<span className="color-neutral">{application.getHost()}</span>
|
<span className="color-neutral">{application.getHost()}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-start justify-between px-3 mb-2">
|
<div className="flex items-start justify-between px-3 mb-2">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { AppState } from '@/ui_models/app_state';
|
|||||||
import { isDev } from '@/utils';
|
import { isDev } from '@/utils';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { FunctionComponent } from 'preact';
|
import { FunctionComponent } from 'preact';
|
||||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
||||||
import { AccountMenuPane } from '.';
|
import { AccountMenuPane } from '.';
|
||||||
import { Button } from '../Button';
|
import { Button } from '../Button';
|
||||||
import { Checkbox } from '../Checkbox';
|
import { Checkbox } from '../Checkbox';
|
||||||
@@ -25,10 +25,12 @@ export const SignInPane: FunctionComponent<Props> = observer(
|
|||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
const [isEphemeral, setIsEphemeral] = useState(false);
|
const [isEphemeral, setIsEphemeral] = useState(false);
|
||||||
|
|
||||||
const [isStrictSignin, setIsStrictSignin] = useState(false);
|
const [isStrictSignin, setIsStrictSignin] = useState(false);
|
||||||
const [isSigningIn, setIsSigningIn] = useState(false);
|
const [isSigningIn, setIsSigningIn] = useState(false);
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [shouldMergeLocal, setShouldMergeLocal] = useState(true);
|
const [shouldMergeLocal, setShouldMergeLocal] = useState(true);
|
||||||
|
const [isVault, setIsVault] = useState(false);
|
||||||
|
|
||||||
const emailInputRef = useRef<HTMLInputElement>(null);
|
const emailInputRef = useRef<HTMLInputElement>(null);
|
||||||
const passwordInputRef = useRef<HTMLInputElement>(null);
|
const passwordInputRef = useRef<HTMLInputElement>(null);
|
||||||
@@ -106,6 +108,16 @@ export const SignInPane: FunctionComponent<Props> = observer(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onVaultChange = useCallback(
|
||||||
|
(newIsVault: boolean, vaultedEmail?: string) => {
|
||||||
|
setIsVault(newIsVault);
|
||||||
|
if (newIsVault && vaultedEmail) {
|
||||||
|
setEmail(vaultedEmail);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[setEmail]
|
||||||
|
);
|
||||||
|
|
||||||
const handleSignInFormSubmit = (e: Event) => {
|
const handleSignInFormSubmit = (e: Event) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -145,7 +157,7 @@ export const SignInPane: FunctionComponent<Props> = observer(
|
|||||||
onChange={handleEmailChange}
|
onChange={handleEmailChange}
|
||||||
onFocus={resetInvalid}
|
onFocus={resetInvalid}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
disabled={isSigningIn}
|
disabled={isSigningIn || isVault}
|
||||||
ref={emailInputRef}
|
ref={emailInputRef}
|
||||||
/>
|
/>
|
||||||
<InputWithIcon
|
<InputWithIcon
|
||||||
@@ -197,25 +209,9 @@ export const SignInPane: FunctionComponent<Props> = observer(
|
|||||||
appState={appState}
|
appState={appState}
|
||||||
application={application}
|
application={application}
|
||||||
disabled={isSigningIn}
|
disabled={isSigningIn}
|
||||||
>
|
onVaultChange={onVaultChange}
|
||||||
<div className="flex justify-between items-center mb-1">
|
onStrictSignInChange={handleStrictSigninChange}
|
||||||
<Checkbox
|
/>
|
||||||
name="use-strict-signin"
|
|
||||||
label="Use strict sign-in"
|
|
||||||
checked={isStrictSignin}
|
|
||||||
disabled={isSigningIn}
|
|
||||||
onChange={handleStrictSigninChange}
|
|
||||||
/>
|
|
||||||
<a
|
|
||||||
href="https://standardnotes.com/help/security"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
title="Learn more"
|
|
||||||
>
|
|
||||||
<Icon type="info" className="color-neutral" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</AdvancedOptions>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import {
|
|||||||
EmailIcon,
|
EmailIcon,
|
||||||
EyeIcon,
|
EyeIcon,
|
||||||
EyeOffIcon,
|
EyeOffIcon,
|
||||||
|
FileIcon,
|
||||||
|
FolderIcon,
|
||||||
FileDocIcon,
|
FileDocIcon,
|
||||||
FileImageIcon,
|
FileImageIcon,
|
||||||
FileMovIcon,
|
FileMovIcon,
|
||||||
@@ -139,6 +141,8 @@ export const ICONS = {
|
|||||||
editor: EditorIcon,
|
editor: EditorIcon,
|
||||||
email: EmailIcon,
|
email: EmailIcon,
|
||||||
eye: EyeIcon,
|
eye: EyeIcon,
|
||||||
|
file: FileIcon,
|
||||||
|
folder: FolderIcon,
|
||||||
hashtag: HashtagIcon,
|
hashtag: HashtagIcon,
|
||||||
help: HelpIcon,
|
help: HelpIcon,
|
||||||
history: HistoryIcon,
|
history: HistoryIcon,
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ export const InputWithIcon: FunctionComponent<Props> = forwardRef(
|
|||||||
className={`pr-2 w-full border-0 focus:shadow-none ${
|
className={`pr-2 w-full border-0 focus:shadow-none ${
|
||||||
disabled ? DISABLED_CLASSNAME : ''
|
disabled ? DISABLED_CLASSNAME : ''
|
||||||
}`}
|
}`}
|
||||||
|
spellcheck={false}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ export const Credentials: FunctionComponent<Props> = observer(
|
|||||||
<Title>Credentials</Title>
|
<Title>Credentials</Title>
|
||||||
<Subtitle>Email</Subtitle>
|
<Subtitle>Email</Subtitle>
|
||||||
<Text>
|
<Text>
|
||||||
You're signed in as <span className="font-bold">{user?.email}</span>
|
You're signed in as{' '}
|
||||||
|
<span className="font-bold wrap">{user?.email}</span>
|
||||||
</Text>
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
className="min-w-20 mt-3"
|
className="min-w-20 mt-3"
|
||||||
|
|||||||
Reference in New Issue
Block a user