Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- angular.module('main')
- .controller('LoginCtrl', function ($log,$scope, $state, Autentificacion, Validate) {
- $scope.user= {};
- $scope.user.username= "";
- $scope.user.password= "";
- $scope.user.mac= "";
- $scope.show=false;
- $scope.signIn = function() {
- if(Validate.validateLoginForm($scope.user)){
- $scope.show=false;
- try{
- window.MacAddress.getMacAddress(
- function(macAddress) {
- $scope.mac=macAddress;
- var credentials = {"username":"user", "password":"pass", "mac":"mac"};
- $log.log(credentials);
- Autentificacion.login(credentials)
- .then(
- function (juanperez){
- console.log(juanperez);
- //$scope.juanito=juanperez;
- //TODO aquí vamos a guardar el token en una cookie
- //TODO aquí va el goTo hacia el home
- },
- function(tarantino){console.log(tarantino)}
- );
- },
- function(fail) {alert(fail);}
- );
- }
- catch(err){
- $scope.user.mac="macAddress";
- var credentials=$scope.user;
- $log.log(credentials);
- Autentificacion.login(credentials)
- .then(
- function (juanperez){
- console.log(juanperez);
- //TODO aquí vamos a guardar el token en una cookie
- $scope.juanito=juanperez.data.token;
- //TODO aquí va el goTo hacia el home
- $state.go('home');
- },
- function(tarantino){
- console.log(tarantino)
- }
- );
- }
- }
- else{
- $scope.show=true;
- }
- };
- $log.log('Hello from your Controller: LoginCtrl in module main:. This is your controller:', this);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement