Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('starter.controllers')
- .controller('LoginCtrl', function ($scope, $state, DataCacheService, $rootScope, User, $ionicPopup, $translate, $ionicLoading, InitializeService) {
- $rootScope.AAuser={password: '', email: ''};
- $scope.login=function () {
- if ($rootScope.AAuser.password != null && $rootScope.AAuser.password.length >= 4) {
- $ionicLoading.show();
- var loginData=$rootScope.AAuser;
- User.login(loginData, function (data, err) {
- $ionicLoading.hide();
- if (data != null && data.token != null && data.userId != null) {
- DataCacheService.clearCache();
- InitializeService.initialize();
- } else {
- $scope.showInvalidCredential();
- }
- });
- }
- else {
- $scope.focusPassword();
- }
- };
- $scope.focusPassword=function () {
- setTimeout(function () {
- cordova.plugins.Keyboard.show();
- document.getElementById("input-password").focus();
- }, 1);
- };
- $scope.showInvalidCredential=function () {
- $translate(['INVALID_CREDENTIALS', 'TRY_AGAIN']).then(function (translations) {
- $ionicPopup.alert({
- title: translations.INVALID_CREDENTIALS,
- template: translations.TRY_AGAIN
- });
- });
- };
- $scope.resetPassword=function () {
- $state.go('ForgotPassword');
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement