more security handling

This commit is contained in:
bwssystems
2017-03-28 18:58:33 -05:00
parent c275926117
commit 7442b0d0ca
3 changed files with 37 additions and 5 deletions

View File

@@ -53,6 +53,9 @@ app.config (function ($locationProvider, $routeProvider) {
}).when ('/lifxdevices', {
templateUrl: 'views/lifxdevice.html',
controller: 'LifxController'
}).when ('/login', {
templateUrl: 'views/login.html',
controller: 'LoginController'
}).otherwise ({
templateUrl: 'views/configuration.html',
controller: 'ViewingController'
@@ -252,6 +255,25 @@ app.service ('bridgeService', function ($http, $base64, ngToast) {
);
};
this.validateUser = function (username, aPassword) {
var newUserInfo = {};
newUserInfo = {
username: username,
password: aPassword
};
var theEncodedPayload = $base64.encode(angular.toJson(newUserInfo));
return $http.post(this.state.systemsbase + "/login", theEncodedPayload ).then(
function (response) {
var theResult = response.data;
self.state.username = theResult.user;
self.displaySuccess("Success!")
},
function (error) {
self.displayWarn("Login Error: ", error);
}
);
};
this.pushLinkButton = function () {
return $http.put(this.state.systemsbase + "/presslinkbutton").then(
function (response) {
@@ -3115,6 +3137,14 @@ app.filter('configuredSomfyDevices', function (bridgeService) {
}
});
app.controller('LoginController', function ($scope, bridgeService) {
$scope.bridge = bridgeService.state;
$scope.login = function(username, password) {
bridgeService.validateUser(username,password);
};
});
app.controller('VersionController', function ($scope, bridgeService) {
$scope.bridge = bridgeService.state;
});