feat: reword storage upgrade migration

This commit is contained in:
Baptiste Grob
2020-07-10 12:40:20 +02:00
parent 6602d35573
commit a81e2f02e5
3 changed files with 56 additions and 14 deletions

View File

@@ -46,6 +46,11 @@ export const STRING_INVALID_IMPORT_FILE = "Unable to open file. Ensure it is a p
export function StringImportError(errorCount: number) { 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.`; 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 */ /** @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."; 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.";

View File

@@ -3,11 +3,7 @@
.sn-component .sn-component
.sk-panel .sk-panel
.sk-panel-header .sk-panel-header
.sk-panel-header-title Authentication Required .sk-panel-header-title {{ctrl.title}}
a.close-button.info(
ng-if="ctrl.cancelable"
ng-click="ctrl.cancel()"
) Cancel
.sk-panel-content .sk-panel-content
.sk-panel-section .sk-panel-section
div(ng-repeat="type in ctrl.state.types") div(ng-repeat="type in ctrl.state.types")
@@ -33,6 +29,11 @@
ng-disabled="ctrl.state.processing" ng-disabled="ctrl.state.processing"
) )
.sk-label {{ctrl.state.processing ? 'Generating Keys...' : 'Submit'}} .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") .sk-panel-footer(ng-if="ctrl.state.showForgotPasscodeLink")
a.sk-panel-row.sk-a.info.centered( a.sk-panel-row.sk-a.info.centered(

View File

@@ -10,7 +10,14 @@ import {
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { WebDirective } from '@/types'; import { WebDirective } from '@/types';
import { confirmDialog } from '@/services/alertService'; 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 = { type InputValue = {
value: string value: string
@@ -57,7 +64,25 @@ class ChallengeModalCtrl extends PureViewCtrl {
invalid: false 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.cancelable = !showForgotPasscodeLink
this.setState({ this.setState({
types, types,
@@ -97,11 +122,22 @@ class ChallengeModalCtrl extends PureViewCtrl {
}); });
} }
promptForChallenge(challenge: ChallengeType) { get title(): string {
if (challenge === ChallengeType.LocalPasscode) { if (this.challenge.reason === ChallengeReason.Migration) {
return 'Enter your application passcode'; return STRING_STORAGE_UPDATE;
} else { } else {
return 'Enter your account password'; return STRING_AUTHENTICATION_REQUIRED;
}
}
promptForChallenge(challenge: ChallengeType): string {
if (challenge === ChallengeType.LocalPasscode) {
if (this.challenge.reason === ChallengeReason.Migration) {
return STRING_ENTER_PASSCODE_FOR_MIGRATION;
}
return STRING_ENTER_ACCOUNT_PASSCODE;
} else {
return STRING_ENTER_ACCOUNT_PASSWORD;
} }
} }
@@ -116,10 +152,10 @@ class ChallengeModalCtrl extends PureViewCtrl {
} }
cancel() { cancel() {
if (!this.cancelable) { if (this.cancelable) {
return; this.application!.cancelChallenge(this.challenge);
this.dismiss();
} }
this.dismiss();
} }
onForgotPasscodeClick() { onForgotPasscodeClick() {