Skip to content

Commit

Permalink
feat: reword storage upgrade migration
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Jul 10, 2020
1 parent 6602d35 commit a81e2f0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 13 deletions.
5 changes: 5 additions & 0 deletions app/assets/javascripts/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export const STRING_INVALID_IMPORT_FILE = "Unable to open file. Ensure it is a p
export function StringImportError(errorCount: number) {
return `Import complete. ${errorCount} items were not imported because there was an error decrypting them. Make sure the password is correct and try again.`;
}
export const STRING_ENTER_ACCOUNT_PASSCODE = 'Enter your application passcode';
export const STRING_ENTER_ACCOUNT_PASSWORD = 'Enter your account password';
export const STRING_ENTER_PASSCODE_FOR_MIGRATION = 'Your application passcode is required to perform an upgrade of your local data storage structure.';
export const STRING_STORAGE_UPDATE = 'Storage Update';
export const STRING_AUTHENTICATION_REQUIRED = 'Authentication Required';

/** @password_change */
export const STRING_FAILED_PASSWORD_CHANGE = "There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup.";
Expand Down
11 changes: 6 additions & 5 deletions app/assets/javascripts/views/challenge_modal/challenge-modal.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
.sn-component
.sk-panel
.sk-panel-header
.sk-panel-header-title Authentication Required
a.close-button.info(
ng-if="ctrl.cancelable"
ng-click="ctrl.cancel()"
) Cancel
.sk-panel-header-title {{ctrl.title}}
.sk-panel-content
.sk-panel-section
div(ng-repeat="type in ctrl.state.types")
Expand All @@ -33,6 +29,11 @@
ng-disabled="ctrl.state.processing"
)
.sk-label {{ctrl.state.processing ? 'Generating Keys...' : 'Submit'}}
.sk-panel-row(ng-if="ctrl.cancelable")
a.sk-panel-row.sk-a.info.centered(
ng-if="ctrl.cancelable"
ng-click="ctrl.cancel()"
) Cancel

.sk-panel-footer(ng-if="ctrl.state.showForgotPasscodeLink")
a.sk-panel-row.sk-a.info.centered(
Expand Down
52 changes: 44 additions & 8 deletions app/assets/javascripts/views/challenge_modal/challenge_modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import {
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { WebDirective } from '@/types';
import { confirmDialog } from '@/services/alertService';
import { STRING_SIGN_OUT_CONFIRMATION } from '@/strings';
import {
STRING_SIGN_OUT_CONFIRMATION,
STRING_ENTER_ACCOUNT_PASSCODE,
STRING_ENTER_ACCOUNT_PASSWORD,
STRING_ENTER_PASSCODE_FOR_MIGRATION,
STRING_STORAGE_UPDATE,
STRING_AUTHENTICATION_REQUIRED
} from '@/strings';

type InputValue = {
value: string
Expand Down Expand Up @@ -57,7 +64,25 @@ class ChallengeModalCtrl extends PureViewCtrl {
invalid: false
};
}
const showForgotPasscodeLink = this.challenge.reason === ChallengeReason.ApplicationUnlock
let showForgotPasscodeLink: boolean;
switch (this.challenge.reason) {
case ChallengeReason.ApplicationUnlock:
showForgotPasscodeLink = true;
this.cancelable = false;
break;
case ChallengeReason.Migration:
showForgotPasscodeLink = true;
this.cancelable = false;
break;
case ChallengeReason.ProtocolUpgrade:
showForgotPasscodeLink = false;
this.cancelable = true;
break;
case ChallengeReason.ResaveRootKey:
showForgotPasscodeLink = false;
this.cancelable = true;
break;
}
this.cancelable = !showForgotPasscodeLink
this.setState({
types,
Expand Down Expand Up @@ -97,11 +122,22 @@ class ChallengeModalCtrl extends PureViewCtrl {
});
}

promptForChallenge(challenge: ChallengeType) {
get title(): string {
if (this.challenge.reason === ChallengeReason.Migration) {
return STRING_STORAGE_UPDATE;
} else {
return STRING_AUTHENTICATION_REQUIRED;
}
}

promptForChallenge(challenge: ChallengeType): string {
if (challenge === ChallengeType.LocalPasscode) {
return 'Enter your application passcode';
if (this.challenge.reason === ChallengeReason.Migration) {
return STRING_ENTER_PASSCODE_FOR_MIGRATION;
}
return STRING_ENTER_ACCOUNT_PASSCODE;
} else {
return 'Enter your account password';
return STRING_ENTER_ACCOUNT_PASSWORD;
}
}

Expand All @@ -116,10 +152,10 @@ class ChallengeModalCtrl extends PureViewCtrl {
}

cancel() {
if (!this.cancelable) {
return;
if (this.cancelable) {
this.application!.cancelChallenge(this.challenge);
this.dismiss();
}
this.dismiss();
}

onForgotPasscodeClick() {
Expand Down

0 comments on commit a81e2f0

Please sign in to comment.