iknb/admin/components/auth/auth.component.js

25 lines
955 B
JavaScript
Raw Normal View History

2020-07-08 11:56:33 +00:00
'use strict';
angular
.module('sloDialectsAdmin')
.component('auth', {
templateUrl: 'components/auth/auth.template.html',
controller: ['$scope', '$rootScope', '$location', 'AuthenticationService',
function ($scope, $rootScope, $location, AuthenticationService) {
// reset login status
AuthenticationService.ClearCredentials();
$scope.login = function () {
$scope.dataLoading = true;
AuthenticationService.Login($scope.username, $scope.password, function(response) {
if(response.success) {
AuthenticationService.SetCredentials($scope.username, $scope.password);
$location.path('/');
} else {
$scope.error = response.message;
$scope.dataLoading = false;
}
});
};
}]
});