I'm having a login page, only selected department members should be accessing the login form else must not.
For eg : If department no : 14 is trying to login, the page must be redirected to next page and if any other department is trying to login, it must display an error message.
EXEC [Sp_User_login] @Username='anantharaj', @password='12345'
Here in my sp by passing parameters like username and password, I'm getting username, password, user id and emp id.
Userid is nothing but the department id.
Now Is there any chance to create access only for userid : 14?
var app = angular.module('homeapp', ['ngStorage']);
app.controller("HomeController", function ($scope, $sessionStorage, $http, $window) {
$scope.btntext = "Login";
$scope.login = function () {
debugger;
$scope.mydata = {};
$http.get("http://stagingserver:85/EBSApi/api/Users/GetAllUsers?username=" + $scope.user.username + "&password=" + $scope.user.password + "")
.then(function (response) {
debugger;
$scope.mydata = JSON.parse(response.data);
$sessionStorage.SessionMessage = response.data;
//$sessionStorage.SessionMessage = "SessionStorage: My name is Mudassar Khan.";
//$window.alert($sessionStorage.SessionMessage);
angular.forEach($scope.mydata, function (item) {
debugger;
$scope.stat = "false";
angular.forEach($scope.mydata, function (item) {
if ((item.username == $scope.user.username) && (item.Password == $scope.user.password)) {
alert("Invalid Username and/or Password!");
}
stat = "true";
//$sessionStorage.SessionMessage = $scope.user.username;
});
$scope.user.username = "";
$scope.user.password = "";
if (stat == "true") {
//var user = JSON.parse($sessionStorage.SessionMessage.replace('[', '').replace(']', ''));
//user.username = user.username.substring(0, 1).toUpperCase() + user.username.substring(1, user.username.length);
window.location.href='http://stagingserver:85/EBSAjs/Views/Warehouse/receipt.html';
}
else
alert("Failure");
})
});
};
$scope.user = {
"username": "",
"password": ""
};
});