summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPliable Pixels <pliablepixels@users.noreply.github.com>2019-08-20 14:26:41 -0400
committerGitHub <noreply@github.com>2019-08-20 14:26:41 -0400
commitbd93725082aee41a342cd27f6df73dbf289a9608 (patch)
tree66251ee4b16970d5bc991c55263d65eb49ab1ef6
parentb36c596f4350ba7e8772044c6601ca5404de1dde (diff)
parentf11b5e9416d808ce92480c164dce389e233609df (diff)
Merge pull request #843 from pliablepixels/what-a-login-mess
What a login mess
-rw-r--r--README.md1
-rw-r--r--config.xml2
-rw-r--r--package.json2
-rw-r--r--www/js/LoginCtrl.js12
-rw-r--r--www/js/MenuController.js4
-rw-r--r--www/js/NVR.js39
-rw-r--r--www/js/PortalLoginCtrl.js7
-rwxr-xr-xwww/js/app.js34
8 files changed, 82 insertions, 19 deletions
diff --git a/README.md b/README.md
index d239c6dc..9ed049d9 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+
[![Donate with Bitcoin](https://en.cryptobadges.io/badge/micro/32YBHDAnnDUWwjsscJQQ1Z92UWJgpsDF86)](https://en.cryptobadges.io/donate/32YBHDAnnDUWwjsscJQQ1Z92UWJgpsDF86) [![Donate with Ethereum](https://en.cryptobadges.io/badge/micro/0x86A5cB50158EFDbd1eCDa872290A7B58857B267a)](https://en.cryptobadges.io/donate/0x86A5cB50158EFDbd1eCDa872290A7B58857B267a) [![Donate with Bountysource](https://img.shields.io/badge/Donate-BountySource-brightgreen.svg)](https://www.bountysource.com/teams/zmninja/)
diff --git a/config.xml b/config.xml
index 385a5f68..5b68627f 100644
--- a/config.xml
+++ b/config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.3.074" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.3.075" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>zmNinja</name>
<description>
High performance ZoneMinder client
diff --git a/package.json b/package.json
index 6268a446..7a8cc3e9 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "zmninjapro",
"description": "Home security mobile app for ZoneMinder",
- "version": "1.3.074",
+ "version": "1.3.075",
"displayName": "zmNinja",
"author": "Pliable Pixels",
"license": "custom see LICENSE.md",
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index 55d384e2..cd6861a8 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -817,6 +817,7 @@ function mobilePinConfig () {
}
+
zmAutoLogin.doLogin("<button class='button button-clear' style='line-height: normal; min-height: 0; min-width: 0; color:#fff;' ng-click='$root.cancelAuth()'><i class='ion-close-circled'></i>&nbsp;" + $translate.instant('kAuthenticating') + "...</button>")
// Do the happy menu only if authentication works
// if it does not work, there is an emitter for auth
@@ -834,13 +835,15 @@ function mobilePinConfig () {
if ($scope.loginData.serverName != NVR.getLogin().serverName) {
NVR.debug(">>> Server information has changed, likely a fallback took over!");
$scope.loginData = NVR.getLogin();
- apiurl = $scope.loginData.apiurl + '/host/getVersion.json?'+$rootScope.authSession;
+
portalurl = $scope.loginData.url + '/index.php';
}
// possible image digits changed between servers
NVR.getKeyConfigParams(0);
-
+ console.log ('In loginCtrl, token is '+$rootScope.authSession);
+ apiurl = $scope.loginData.apiurl + '/host/getVersion.json?'+$rootScope.authSession;
+
NVR.log("Validating APIs at " + apiurl);
$http.get(apiurl)
.then(function (data) {
@@ -879,6 +882,11 @@ function mobilePinConfig () {
},
function (error) {
+
+ if ($rootScope.userCancelledAuth) {
+ return;
+ }
+
NVR.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]);
NVR.log("API login error " + JSON.stringify(error));
diff --git a/www/js/MenuController.js b/www/js/MenuController.js
index 8496acff..318e4d15 100644
--- a/www/js/MenuController.js
+++ b/www/js/MenuController.js
@@ -324,6 +324,10 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
},
function (error) {
+
+ if ($rootScope.userCancelledAuth) {
+ return;
+ }
NVR.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]);
NVR.log("API login error " + JSON.stringify(error));
diff --git a/www/js/NVR.js b/www/js/NVR.js
index 0f5a0656..d785683a 100644
--- a/www/js/NVR.js
+++ b/www/js/NVR.js
@@ -21,7 +21,7 @@ angular.module('zmApp.controllers')
DO NOT TOUCH zmAppVersion
It is changed by sync_version.sh
*/
- var zmAppVersion = "1.3.074";
+ var zmAppVersion = "1.3.075";
var isBackground = false;
var justResumed = false;
var timeSinceResumed = -1;
@@ -399,7 +399,9 @@ angular.module('zmApp.controllers')
var httpDelay = loginData.enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout;
- str = $translate.instant('kAuthenticating');
+ str = "<a style='color:white; text-decoration:none' href='#' ng-click='$root.cancelAuth()' <i class='ion-close-circled'></i>&nbsp;" + $translate.instant('kAuthenticating')+"</a>";
+
+
if (str) {
$ionicLoading.show({
@@ -590,16 +592,23 @@ angular.module('zmApp.controllers')
function loginWebScrape(noBroadcast) {
var d = $q.defer();
+ if ($rootScope.userCancelledAuth) {
+ debug ('NVR loginWebScrape: User cancelled auth, not proceeding');
+ d.reject(true);
+ return d.promise;
+ }
debug("Logging in using old web-scrape method");
$ionicLoading.show({
- template: $translate.instant('kAuthenticatingWebScrape'),
+
+ template: "<a style='color:white; text-decoration:none' href='#' ng-click='$root.cancelAuth()' <i class='ion-close-circled'></i>&nbsp;" + $translate.instant('kAuthenticatingWebScrape')+"</a>",
noBackdrop: true,
duration: httpDelay
});
-
+
+
var httpDelay = loginData.enableSlowLoading ? zm.largeHttpTimeout : zm.httpTimeout;
//NVR.debug ("*** AUTH LOGIN URL IS " + loginData.url);
@@ -1793,8 +1802,12 @@ angular.module('zmApp.controllers')
function findFirstReachableUrl(urls) {
if (urls.length > 0 && $rootScope.userCancelledAuth != true) {
+
+
+
$ionicLoading.show({
- template: $translate.instant('kTrying') + ' ' + urls[0].server
+ template: "<a style='color:white; text-decoration:none' href='#' ng-click='$root.cancelAuth()' <i class='ion-close-circled'></i>&nbsp;" + $translate.instant('kTrying')+ ' ' + urls[0].server+"</a>",
+ noBackdrop: true,
});
log("Reachability test.." + urls[0].url);
@@ -2958,9 +2971,10 @@ angular.module('zmApp.controllers')
}, diff_access * 60 * 1000);
- // console.log ("**************** TOKEN SET="+loginData.accessToken);
+
$rootScope.authSession = '&token='+loginData.accessToken;
d.resolve("Login success via access token");
+ console.log ("**************** TOKEN SET="+$rootScope.authSession);
if (!noBroadcast) $rootScope.$broadcast('auth-success', '' );
return d.promise;
}
@@ -3623,7 +3637,11 @@ angular.module('zmApp.controllers')
logout: function () {
var d = $q.defer();
-
+ if ($rootScope.userCancelledAuth) {
+ debug ('NVR logout: User cancelled auth, not proceeding');
+ d.reject(true);
+ return d.promise;
+ }
// always resolves
if (!loginData.isUseAuth || loginData.isTokenSupported) {
log("No need for logout!");
@@ -3631,8 +3649,13 @@ angular.module('zmApp.controllers')
return d.promise;
}
+
+ // $ionicLoading.show({ template: '<button class="button button-clear" style="line-height: normal; min-height: 0; min-width: 0;" ng-click="$root.cancel()"></button><i class="icon ion-chevron-up"></i> Loading...' });
+
+
$ionicLoading.show({
- template: $translate.instant('kCleaningUp'),
+ //template:$translate.instant('kCleaningUp'),
+ template: "<a style='color:white; text-decoration:none' href='#' ng-click='$root.cancelAuth()' <i class='ion-close-circled'></i>&nbsp;" + $translate.instant('kCleaningUp')+"</a>",
noBackdrop: true,
});
diff --git a/www/js/PortalLoginCtrl.js b/www/js/PortalLoginCtrl.js
index 17715238..192c0c4e 100644
--- a/www/js/PortalLoginCtrl.js
+++ b/www/js/PortalLoginCtrl.js
@@ -470,12 +470,19 @@ angular.module('zmApp.controllers').controller('zmApp.PortalLoginCtrl', ['$ionic
},
function error(e) {
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+
if ($rootScope.apiValid == true) {
$state.go("app.login", {
"wizard": false
});
return;
} else {
+ NVR.log ('Portal login:invalid api');
+ if (!$rootScope.userCancelledAuth)
$state.go("app.invalidapi");
return;
}
diff --git a/www/js/app.js b/www/js/app.js
index 3545cb2a..1d3d1250 100755
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -1007,9 +1007,12 @@ angular.module('zmApp', [
$cookies.remove(k);
});
}*/
+
+ $rootScope.userCancelledAuth = false;
return NVR.getReachableConfig(false)
.then (
function(data ) {
+
return NVR.logout()
.then(function (ans) {
return _doLogin(str);
@@ -1018,16 +1021,30 @@ angular.module('zmApp', [
},
function (err) {
NVR.log('No reachable config: '+JSON.stringify(err));
- $state.go("app.invalidapi");
+ $ionicHistory.nextViewOptions({
+ disableAnimate:true,
+ disableBack: true
+ });
+ if (!$rootScope.userCancelledAuth)
+ $state.go("app.invalidapi");
return;
}
);
+
+
+
}
function _doLogin(str) {
var d = $q.defer();
+
+ if ($rootScope.userCancelledAuth) {
+ NVR.debug ('_doLogin - not proceeding as user cancelled auth');
+ d.reject(false);
+ return d.promise;
+ }
var ld = NVR.getLogin();
//var statename = $ionicHistory.currentStateName();
@@ -1511,9 +1528,10 @@ angular.module('zmApp', [
disableBack: true
});
$rootScope.userCancelledAuth = true;
- window.stop();
+ //window.stop();
//console.log ("inside cancelAuth , calling wizard");
+ //$ionicSideMenuDelegate.toggleLeft();
$state.go("app.login", {
"wizard": false
});
@@ -1532,9 +1550,10 @@ angular.module('zmApp', [
if ($rootScope.apiValid == false && toState.name != 'app.invalidapi' && toState.data.requireLogin == true) {
- event.preventDefault();
+ /*event.preventDefault();
$rootScope.dpadState = "app.invalidapi";
- $state.transitionTo('app.invalidapi');
+ $state.transitionTo('app.invalidapi');*/
+ NVR.log ('API not valid, not going to this state');
return;
}
@@ -1582,6 +1601,7 @@ angular.module('zmApp', [
// if you don't prevent, states will stack
event.preventDefault();
$rootScope.dpadState = "login";
+
$state.transitionTo('app.login');
return;
}
@@ -2047,7 +2067,7 @@ angular.module('zmApp', [
//$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|cdvphotolibrary):/);
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|content|cdvphotolibrary|blob|unsafe|local):|data:image\//);
- $provide.decorator("$exceptionHandler", ['$delegate', '$injector', function ($delegate, $injector) {
+ $provide.decorator("$exceptionHandler", ['$delegate', '$injector', function ($delegate, $injector) {
return function (exception, cause) {
var $rootScope = $injector.get("$rootScope");
@@ -2056,10 +2076,10 @@ angular.module('zmApp', [
cause: cause
});
- $delegate(exception, cause);
+ $delegate(exception, cause);
};
- }]);
+ }]);
// Wraps around $http that switches between browser XHR