import * as React from 'react'; import { Action } from 'redux-actions'; import Container from './widgets/Container'; import ExternalLink from './widgets/ExternalLink'; import SyncGate from './SyncGate'; import LoginForm from './components/LoginForm'; import EncryptionLoginForm from './components/EncryptionLoginForm'; import { store, CredentialsType } from './store'; import { deriveKey, fetchCredentials, fetchUserInfo } from './store/actions'; import * as EteSync from 'etesync'; import * as C from './constants'; import SignedPagesBadge from './images/signed-pages-badge.svg'; import LoadingIndicator from './widgets/LoadingIndicator'; function EncryptionPart(props: { credentials: CredentialsType }) { const [fetched, setFetched] = React.useState(false); const [userInfo, setUserInfo] = React.useState(); const [error, setError] = React.useState(); const credentials = props.credentials.value!; React.useEffect(() => { // FIXME: verify the error is a 404 store.dispatch(fetchUserInfo(credentials, credentials.credentials.email)).then((fetchedUserInfo: Action) => { setUserInfo(fetchedUserInfo.payload); }).finally(() => { setFetched(true); }); }, [credentials]); if (!fetched) { return ; } function onEncryptionFormSubmit(encryptionPassword: string) { const derivedAction = deriveKey(props.credentials.value!.credentials.email, encryptionPassword); if (userInfo) { const userInfoCryptoManager = userInfo.getCryptoManager(derivedAction.payload!); try { userInfo.verify(userInfoCryptoManager); } catch (e) { setError(new EteSync.EncryptionPasswordError('Wrong encryption password')); return; } } store.dispatch(derivedAction); } const isNewUser = !userInfo; return (

Encryption Password

{(isNewUser) ?

Welcome to EteSync!

Please set your encryption password below, and make sure you got it right, as it can't be recovered if lost!

:

You are logged in as {credentials.credentials.email}. Please enter your encryption password to continue, or log out from the side menu.

}
); } class LoginGate extends React.Component { public props: { credentials: CredentialsType; }; constructor(props: any) { super(props); this.onFormSubmit = this.onFormSubmit.bind(this); } public onFormSubmit(username: string, password: string, serviceApiUrl?: string) { serviceApiUrl = serviceApiUrl ? serviceApiUrl : C.serviceApiBase; store.dispatch(fetchCredentials(username, password, serviceApiUrl)); } public render() { if (this.props.credentials.value === null) { const style = { isSafe: { textDecoration: 'none', display: 'block', }, divider: { margin: '30px 0', color: '#00000025', }, }; return (

Please Log In


SignedPgaes badge
  • The EteSync Website
  • Is the web client safe to use?
  • Source code
); } else if (this.props.credentials.value.encryptionKey === null) { return ( ); } return ( ); } } export default LoginGate;