Skip to content

Commit

Permalink
#668 switch to login API
Browse files Browse the repository at this point in the history
  • Loading branch information
pliablepixels committed Jul 12, 2018
1 parent 9c29844 commit 536254f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
3 changes: 3 additions & 0 deletions www/js/WizardCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ angular.module('zmApp.controllers').controller('zmApp.WizardCtrl', ['$scope', '$
function login(u, zmu, zmp) {
var d = $q.defer();




$http({
method: 'POST',
//withCredentials: true,
Expand Down
51 changes: 24 additions & 27 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,46 +1032,43 @@ angular.module('zmApp', [


//first login using new API
var loginAPI = loginData.apiurl + '/host/getVersion.json?user=' + loginData.username + "&pass=" + loginData.password;
var loginAPI = loginData.apiurl + '/host/login.json?user=' + loginData.username + "&pass=" + loginData.password;

$http.get(loginAPI)
.then(function (succ) {

console.log("******************* NEW API LOGIN RETURNED " + JSON.stringify(succ));
NVRDataModel.debug ("API based login returned: "+JSON.stringify(succ));
NVRDataModel.setCurrentServerVersion(succ.data.version);
$ionicLoading.hide();
$rootScope.loggedIntoZm = 1;
$rootScope.authSession = '';

if (succ.data.credentials) {
$rootScope.authSession = "&" + succ.data.credentials;
if (succ.data.append_password == '1') {
$rootScope.authSession = $rootScope.authSession +
loginData.password;
}
}

NVRDataModel.log("Stream authentication construction: " +
$rootScope.authSession);

NVRDataModel.log("zmAutologin successfully logged into Zoneminder via API");

/*
{
"credentials": "auth=fsdfdsfsd,
"append_password": 0,
"version": "1.31.44",
"apiversion": "1.0"
}
*/

d.resolve("Login Success");

$rootScope.$broadcast('auth-success', succ);

// Now go ahead and re-get auth key
// if login was a success
$rootScope.authSession = "undefined";
var ld = NVRDataModel.getLogin();
NVRDataModel.getAuthKey($rootScope.validMonitorId)
.then(function (success) {

//console.log(success);
$rootScope.authSession = success;
NVRDataModel.log("Stream authentication construction: " +
$rootScope.authSession);

},
function (error) {
//console.log(error);

NVRDataModel.log("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession);
NVRDataModel.debug("Error was: " + JSON.stringify(error));
});






},
function (err) {
console.log("******************* API login error " + JSON.stringify(err));
Expand Down

0 comments on commit 536254f

Please sign in to comment.