Просмотр исходного кода

Lock input field when reconnecting to session

This prevents a race condition, causing a wrong password to be used to
store the session.

Fixes #445
Danilo Bargen 7 лет назад
Родитель
Сommit
ce23be2306
2 измененных файлов с 7 добавлено и 0 удалено
  1. 1 0
      src/partials/welcome.html
  2. 6 0
      src/partials/welcome.ts

+ 1 - 0
src/partials/welcome.html

@@ -36,6 +36,7 @@
                         <md-input-container md-no-float class="md-block">
                             <input type="password"
                                    ng-model="ctrl.password"
+                                   ng-disabled="ctrl.formLocked"
                                    autofocus
                                    aria-label="Password"
                                    translate-attr="{'placeholder': 'welcome.PASSWORD', 'aria-label': 'welcome.PASSWORD'}"

+ 6 - 0
src/partials/welcome.ts

@@ -75,6 +75,7 @@ class WelcomeController {
     private mode: 'scan' | 'unlock';
     private qrCode;
     private password: string = '';
+    private formLocked: boolean = false;
     private pleaseUpdateAppMsg: string = null;
     private browser: threema.BrowserInfo;
 
@@ -265,6 +266,9 @@ class WelcomeController {
      * Decrypt the keys and initiate the session.
      */
     private unlockConfirm(): void {
+        // Lock form to prevent further input
+        this.formLocked = true;
+
         const decrypted: threema.TrustedKeyStoreData = this.trustedKeyStore.retrieveTrustedKey(this.password);
         if (decrypted === null) {
             return this.showDecryptionFailed();
@@ -460,6 +464,7 @@ class WelcomeController {
             // Go back to scan mode
             this.mode = 'scan';
             this.password = '';
+            this.formLocked = false;
 
             // Initiate scan
             this.scan();
@@ -523,6 +528,7 @@ class WelcomeController {
 
                 // Clear local password variable
                 this.password = '';
+                this.formLocked = false;
 
                 // Redirect to home
                 this.$timeout(() => this.$state.go('messenger.home'), WelcomeController.REDIRECT_DELAY);