Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. /* var response;
  2. if($scope.username == 'admin' && $scope.password =='admin'){
  3. response = {success: true};
  4. } else {
  5. response = {success: false, message: 'Username or password is incorrect'};
  6. }*/
  7. // callback(response);
  8. // Service Calls Function : userLogin
  9. // Parameters : $scope.username,$scope.password
  10. AuthenticationServiceLogin.userLogin($scope.username,$scope.password, function (response) {
  11. console.log(response.success);
  12. if(response.success)
  13. {
  14. AuthenticationServiceLogin.SetCredentials(response);
  15. toaster.pop('success', "", "Login Successful");
  16. $location.path('/home');
  17. }
  18.  
  19. if (response.status ==200) {
  20.  
  21.  
  22.  
  23. var stompCtrl = $rootScope.$new();
  24. $controller('StompController', { $scope: stompCtrl });
  25.  
  26.  
  27. toaster.pop('success', "", "Login Successful");
  28. $location.path('/home');
  29. }
  30. else if(response.status ==401){
  31. toaster.pop('error', response.status+" "+response.statusText," Access is denied due to invalid credentials");
  32. $scope.dataLoading = false;
  33. }
  34. else {
  35. toaster.pop('error', "Username / Password", "Username or password is incorrect");
  36. $scope.dataLoading = false;
  37. }
  38. });
  39. };
  40.  
  41. });
  42.  
  43. if(username == 'admin' && password =='admin'){
  44. response = {success: true};
  45. }
  46.  
  47. callback(response);
  48. }, 900);
  49.  
  50. }
  51.  
  52. };
  53. spyOn(AuthenticationServiceLogin,'userLogin').and.returnValue(response);
  54. spyOn(AuthenticationServiceLogin,'forgetPassword').and.returnValue(response);
  55. }));
  56.  
  57. var $scope = {};
  58. var $rootscope = {};
  59. var $location = {};
  60. var $cookieStore = {};
  61. var $http = {};
  62. var $controller = {};
  63. var FlashService = {};
  64. var controller = $controller1('loginCtrl',{
  65. $scope: $scope,
  66. $rootscope: $rootscope,
  67. $location: $location,
  68. $window: $window,
  69. $cookieStore:$cookieStore,
  70. AuthenticationServiceLogin:AuthenticationServiceLogin,
  71. FlashService:FlashService,
  72. $http:$http,
  73. $controller:$controller
  74. });
  75.  
  76. $scope.username="admin";
  77. $scope.password="admin";
  78.  
  79. $scope.login();
  80.  
  81. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement