Link flow: Show 'you must upgrade' on 409 server response

This commit is contained in:
Scott Nonnenberg 2020-05-05 12:46:42 -07:00
parent 97b657da6d
commit d13c3d3350
5 changed files with 85 additions and 53 deletions

View File

@ -1076,6 +1076,15 @@
"installTooManyDevices": {
"message": "Sorry, you have too many devices linked already. Try removing some."
},
"installTooOld": {
"message": "Update Signal on this device to link your phone."
},
"installErrorHeader": {
"message": "Something went wrong!"
},
"installTryAgain": {
"message": "Try again"
},
"theme": {
"message": "Theme",
"description": "Header for theme settings"

View File

@ -306,6 +306,9 @@
</div>
<div class='nav'>
<a class='button try-again'>{{ errorButton }}</a>
{{#errorSecondButton}}
<a class='button second'>{{ errorSecondButton }}</a>
{{/errorSecondButton}}
</div>
</div>
</div>

View File

@ -20,12 +20,14 @@
const DEVICE_NAME_SELECTOR = 'input.device-name';
const CONNECTION_ERROR = -1;
const TOO_MANY_DEVICES = 411;
const TOO_OLD = 409;
Whisper.InstallView = Whisper.View.extend({
templateName: 'link-flow-template',
className: 'main full-screen-flow',
events: {
'click .try-again': 'connect',
'click .second': 'shutdown',
'click .finish': 'finishLinking',
// the actual next step happens in confirmNumber() on submit form #link-phone
},
@ -43,6 +45,8 @@
},
render_attributes() {
let errorMessage;
let errorButton = i18n('installTryAgain');
let errorSecondButton = null;
if (this.error) {
if (
@ -50,6 +54,13 @@
this.error.code === TOO_MANY_DEVICES
) {
errorMessage = i18n('installTooManyDevices');
} else if (
this.error.name === 'HTTPError' &&
this.error.code === TOO_OLD
) {
errorMessage = i18n('installTooOld');
errorButton = i18n('upgrade');
errorSecondButton = i18n('quit');
} else if (
this.error.name === 'HTTPError' &&
this.error.code === CONNECTION_ERROR
@ -63,9 +74,10 @@
return {
isError: true,
errorHeader: 'Something went wrong!',
errorHeader: i18n('installErrorHeader'),
errorMessage,
errorButton: 'Try again',
errorButton,
errorSecondButton,
};
}
@ -89,7 +101,19 @@
this.step = step;
this.render();
},
shutdown() {
window.shutdown();
},
connect() {
if (
this.error &&
this.error.name === 'HTTPError' &&
this.error.code === TOO_OLD
) {
window.location = 'https://signal.org/download';
return;
}
this.error = null;
this.selectStep(Steps.SCAN_QR_CODE);
this.clearQR();

View File

@ -917,9 +917,13 @@ export function initialize({
) {
const { accessKey } = options;
const jsonData: any = {
supportsSms: false,
capabilities: {
uuid: true,
},
fetchesMessages: true,
name: deviceName ? deviceName : undefined,
registrationId,
supportsSms: false,
unidentifiedAccessKey: accessKey
? _btoa(_getString(accessKey))
: undefined,
@ -929,14 +933,6 @@ export function initialize({
const call = deviceName ? 'devices' : 'accounts';
const urlPrefix = deviceName ? '/' : '/code/';
if (deviceName) {
jsonData.name = deviceName;
} else {
jsonData.capabilities = {
uuid: true,
};
}
// We update our saved username and password, since we're creating a new account
username = number;
password = newPassword;

View File

@ -586,7 +586,7 @@
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#qr img').remove();",
"lineNumber": 136,
"lineNumber": 160,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"reasonDetail": "Protected from arbitrary input"
@ -595,7 +595,7 @@
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#qr .container').show();",
"lineNumber": 138,
"lineNumber": 162,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"reasonDetail": "Protected from arbitrary input"
@ -604,7 +604,7 @@
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " if ($('#qr').length === 0) {",
"lineNumber": 142,
"lineNumber": 166,
"reasonCategory": "usageTrusted",
"updated": "2018-09-19T21:59:32.770Z",
"reasonDetail": "Protected from arbitrary input"
@ -613,7 +613,7 @@
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#qr .container').hide();",
"lineNumber": 148,
"lineNumber": 172,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
@ -622,7 +622,7 @@
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.qr = new QRCode(this.$('#qr')[0]).makeCode(url);",
"lineNumber": 149,
"lineNumber": 173,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
@ -631,52 +631,52 @@
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#qr').addClass('ready');",
"lineNumber": 151,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$(DEVICE_NAME_SELECTOR).val(deviceName || window.getHostName());",
"lineNumber": 156,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#link-phone').submit();",
"lineNumber": 161,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#link-phone').submit(e => {",
"lineNumber": 171,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " let name = this.$(DEVICE_NAME_SELECTOR).val();",
"lineNumber": 175,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$(DEVICE_NAME_SELECTOR).val(deviceName || window.getHostName());",
"lineNumber": 180,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#link-phone').submit();",
"lineNumber": 185,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$('#link-phone').submit(e => {",
"lineNumber": 195,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " let name = this.$(DEVICE_NAME_SELECTOR).val();",
"lineNumber": 199,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"
},
{
"rule": "jQuery-$(",
"path": "js/views/install_view.js",
"line": " this.$(DEVICE_NAME_SELECTOR).focus();",
"lineNumber": 178,
"lineNumber": 202,
"reasonCategory": "usageTrusted",
"updated": "2020-03-24T19:03:04.861Z",
"reasonDetail": "Protected from arbitrary input"