mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
more security handling
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user