Advertisement
Guest User

Untitled

a guest
Jan 20th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. angular.module('starter.controllers')
  2. .controller('LoginCtrl', function ($scope, $state, DataCacheService, $rootScope, User, $ionicPopup, $translate, $ionicLoading, InitializeService) {
  3.  
  4. $rootScope.AAuser={password: '', email: ''};
  5.  
  6. $scope.login=function () {
  7. if ($rootScope.AAuser.password != null && $rootScope.AAuser.password.length >= 4) {
  8.  
  9. $ionicLoading.show();
  10. var loginData=$rootScope.AAuser;
  11. User.login(loginData, function (data, err) {
  12. $ionicLoading.hide();
  13.  
  14. if (data != null && data.token != null && data.userId != null) {
  15. DataCacheService.clearCache();
  16. InitializeService.initialize();
  17. } else {
  18. $scope.showInvalidCredential();
  19. }
  20.  
  21. });
  22. }
  23. else {
  24. $scope.focusPassword();
  25. }
  26. };
  27.  
  28. $scope.focusPassword=function () {
  29. setTimeout(function () {
  30. cordova.plugins.Keyboard.show();
  31. document.getElementById("input-password").focus();
  32. }, 1);
  33. };
  34.  
  35. $scope.showInvalidCredential=function () {
  36. $translate(['INVALID_CREDENTIALS', 'TRY_AGAIN']).then(function (translations) {
  37. $ionicPopup.alert({
  38. title: translations.INVALID_CREDENTIALS,
  39. template: translations.TRY_AGAIN
  40. });
  41. });
  42. };
  43.  
  44. $scope.resetPassword=function () {
  45. $state.go('ForgotPassword');
  46. };
  47.  
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement