From ef926328852a7bac54090c3b9b988a9b483faf3f Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 4 Dec 2017 14:44:52 +0000 Subject: [PATCH] Change to the production API and allow setting a custom server. --- src/Constants.tsx | 2 +- src/EteSyncContext.tsx | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Constants.tsx b/src/Constants.tsx index 301fe8d..d2d2f49 100644 --- a/src/Constants.tsx +++ b/src/Constants.tsx @@ -4,4 +4,4 @@ export const faq = homePage + 'faq/'; export const sourceCode = 'https://github.com/etesync/etesync-web'; export const reportIssue = sourceCode + '/issues'; -export const serviceApiBase = 'http://localhost:8000'; +export const serviceApiBase = 'https://api.etesync.com/'; diff --git a/src/EteSyncContext.tsx b/src/EteSyncContext.tsx index 70d3956..fd014b1 100644 --- a/src/EteSyncContext.tsx +++ b/src/EteSyncContext.tsx @@ -25,6 +25,7 @@ export interface EteSyncContextType { } export class EteSyncContext extends React.Component { + server: HTMLInputElement; username: HTMLInputElement; password: HTMLInputElement; encryptionPassword: HTMLInputElement; @@ -54,7 +55,9 @@ export class EteSyncContext extends React.Component { generateEncryption(e: any) { e.preventDefault(); - let authenticator = new EteSync.Authenticator(C.serviceApiBase); + const server = this.server.value; + + let authenticator = new EteSync.Authenticator(server); this.setState({ loadState: LoadState.Working @@ -69,7 +72,7 @@ export class EteSyncContext extends React.Component { const derived = EteSync.deriveKey(username, encryptionPassword); const context = { - serviceApiUrl: C.serviceApiBase, + serviceApiUrl: server, credentials, encryptionKey: derived, }; @@ -95,12 +98,22 @@ export class EteSyncContext extends React.Component { {(this.state.error !== undefined) && (
Error! {this.state.error.message}
)}
this.username = input as HTMLInputElement} /> - this.password = input as HTMLInputElement} /> + this.password = input as HTMLInputElement} + /> this.encryptionPassword = input as HTMLInputElement} /> + this.server = input as HTMLInputElement} + defaultValue={C.serviceApiBase} + />