From 9e8425bb711083558eace598ff5acc5203db6772 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 13 Nov 2014 14:21:30 +0300 Subject: [PATCH] Added https redirect for unauthorised users Remove mixed content warning --- app/js/controllers.js | 33 +++---------------------- app/js/locales/en-us.json | 1 - app/partials/desktop/confirm_modal.html | 4 --- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 65e782c8..47601d17 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -33,6 +33,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) $location.url('/im'); return; } + if (location.protocol == 'http:' && + (location.host == 'zhukov.github.io' || location.host == 'web.telegram.org')) { + location = 'https://web.telegram.org'; + } }); var options = {dcID: 2, createNetworker: true}, countryChanged = false, @@ -80,17 +84,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) if (nearestDcResult.nearest_dc != nearestDcResult.this_dc) { MtpApiManager.getNetworker(nearestDcResult.nearest_dc, {createNetworker: true}); } - }, function (error) { - switch (error.type) { - case 'NETWORK_BAD_REQUEST': - if (location.protocol == 'https:') { - ErrorService.confirm({type: 'HTTPS_MIXED_FAIL'}).then(function () { - location = location.toString().replace(/^https:/, 'http:'); - }); - error.handled = true; - } - break; - } }); } @@ -218,15 +211,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.progress.enabled = false; console.log('sendCode error', error); switch (error.type) { - case 'NETWORK_BAD_REQUEST': - if (location.protocol == 'https:') { - ErrorService.confirm({type: 'HTTPS_MIXED_FAIL'}).then(function () { - location = location.toString().replace(/^https:/, 'http:'); - }); - error.handled = true; - } - break; - case 'PHONE_NUMBER_INVALID': $scope.error = {field: 'phone'}; error.handled = true; @@ -617,15 +601,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) return result; }, function (error) { - if (error.type == 'NETWORK_BAD_REQUEST') { - if (location.protocol == 'https:') { - ErrorService.confirm({type: 'HTTPS_MIXED_FAIL'}).then(function () { - location = location.toString().replace(/^https:/, 'http:'); - }); - error.handled = true; - } - } - if (error.code == 401) { MtpApiManager.logOut()['finally'](function () { location.hash = '/login'; diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 36f40fbc..5d3bda33 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -119,7 +119,6 @@ "confirm_modal_update_reload": "A new version of Telegram Web has been downloaded. Launch it?", "confirm_modal_history_flush": "Are you sure? This can not be undone!", "confirm_modal_terminate_sessions": "Are you sure you want to log out all devices except for the current one?", - "confirm_modal_mixed_content_fail_http_redirect_md": "Your browser {moz-link: does not support} mixed content which is neccessary for MTProto support on https. {issue-link: Learn more}\n\n Would you like to use http-version instead?", "confirm_modal_clipboard_file_send": "Are you sure to send file(s) from clipboard?", "confirm_modal_clipboard_X_files_send": "{'one': 'Are you sure to send file from clipboard?', 'other': 'Are you sure to send {} files from clipboard?'}", "confirm_modal_message_delete": "Are you sure you want to delete the message?", diff --git a/app/partials/desktop/confirm_modal.html b/app/partials/desktop/confirm_modal.html index fd7d801a..7990cd6e 100644 --- a/app/partials/desktop/confirm_modal.html +++ b/app/partials/desktop/confirm_modal.html @@ -9,10 +9,6 @@ - - {0} - {0} » -