Skip to content

Instantly share code, notes, and snippets.

@FraGoTe
Created January 27, 2015 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FraGoTe/3dad937869715e749a23 to your computer and use it in GitHub Desktop.
Save FraGoTe/3dad937869715e749a23 to your computer and use it in GitHub Desktop.
'use strict';
angular.module('Authentication', ['TCS'])
.controller('LoginController',
['$scope', '$rootScope', '$location', 'AuthenticationService',
function ($scope, $rootScope, $location, AuthenticationService, tcs_modal) {
// reset login status
AuthenticationService.ClearCredentials();
$scope.login = function (user) {
tcs_modal(1, 'Cargando ...', '');
console.log('xx');
AuthenticationService.Login(user.username, user.password, function(response) {
if(response.transaccion === SUCCESS) {
// TCS.modal(0, '', '');
$scope.v_success = true;
$scope.v_error = false;
$scope.v_mensaje = response.mensaje;
AuthenticationService.SetCredentials(user.username, user.password);
$location.path('/');
} else {
// TCS.modal(0, '', '');
$scope.v_success = false;
$scope.v_error = true;
$scope.v_mensaje = response.mensaje;
}
});
};
}]);
'use strict';
angular.module('TCS', [])
.factory('tcs_modal', function(mostrar, mensaje, mensajeHtml) {
var modalTrns = 'hide';
if (mostrar === 1) {
modalTrns = 'show';
}
$.mobile.loading( modalTrns, {
text: mensaje,
textVisible: true,
theme: 'b',
html: mensajeHtml
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment