Change to the production API and allow setting a custom server.

master
Tom Hacohen 7 years ago
parent 0a05095da2
commit ef92632885

@ -4,4 +4,4 @@ export const faq = homePage + 'faq/';
export const sourceCode = 'https://github.com/etesync/etesync-web'; export const sourceCode = 'https://github.com/etesync/etesync-web';
export const reportIssue = sourceCode + '/issues'; export const reportIssue = sourceCode + '/issues';
export const serviceApiBase = 'http://localhost:8000'; export const serviceApiBase = 'https://api.etesync.com/';

@ -25,6 +25,7 @@ export interface EteSyncContextType {
} }
export class EteSyncContext extends React.Component { export class EteSyncContext extends React.Component {
server: HTMLInputElement;
username: HTMLInputElement; username: HTMLInputElement;
password: HTMLInputElement; password: HTMLInputElement;
encryptionPassword: HTMLInputElement; encryptionPassword: HTMLInputElement;
@ -54,7 +55,9 @@ export class EteSyncContext extends React.Component {
generateEncryption(e: any) { generateEncryption(e: any) {
e.preventDefault(); e.preventDefault();
let authenticator = new EteSync.Authenticator(C.serviceApiBase); const server = this.server.value;
let authenticator = new EteSync.Authenticator(server);
this.setState({ this.setState({
loadState: LoadState.Working loadState: LoadState.Working
@ -69,7 +72,7 @@ export class EteSyncContext extends React.Component {
const derived = EteSync.deriveKey(username, encryptionPassword); const derived = EteSync.deriveKey(username, encryptionPassword);
const context = { const context = {
serviceApiUrl: C.serviceApiBase, serviceApiUrl: server,
credentials, credentials,
encryptionKey: derived, encryptionKey: derived,
}; };
@ -95,12 +98,22 @@ export class EteSyncContext extends React.Component {
{(this.state.error !== undefined) && (<div>Error! {this.state.error.message}</div>)} {(this.state.error !== undefined) && (<div>Error! {this.state.error.message}</div>)}
<form onSubmit={this.generateEncryption}> <form onSubmit={this.generateEncryption}>
<input type="text" placeholder="Username" ref={(input) => this.username = input as HTMLInputElement} /> <input type="text" placeholder="Username" ref={(input) => this.username = input as HTMLInputElement} />
<input type="password" placeholder="Password" ref={(input) => this.password = input as HTMLInputElement} /> <input
type="password"
placeholder="Password"
ref={(input) => this.password = input as HTMLInputElement}
/>
<input <input
type="password" type="password"
placeholder="Encryption Password" placeholder="Encryption Password"
ref={(input) => this.encryptionPassword = input as HTMLInputElement} ref={(input) => this.encryptionPassword = input as HTMLInputElement}
/> />
<input
type="text"
placeholder="Server"
ref={(input) => this.server = input as HTMLInputElement}
defaultValue={C.serviceApiBase}
/>
<button>Submit</button> <button>Submit</button>
</form> </form>
</div> </div>

Loading…
Cancel
Save