angular.module('admin')
  .controller('LoginController', function ($scope, $http, $location, $window) {
    $scope.login = {};
    $scope.mensagem = '';
    $scope.dock = [];

    $scope.submeter = function () {
      $http.post("../../api/club/seller", $scope.login)
        .then(function (dock) {
          $scope.dock = dock;
          $window.sessionStorage.dock = $scope.dock.data[0];
          $window.sessionStorage.name = $scope.dock.data[1];
          if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
            $location.path("/codigodebarras");            
          } else {
            $location.path("/dash");
          }

        }, function (err) {
          $scope.login = $scope.login;
          $scope.mensagem = 'Atenção: Informações inválidas!';
        });
    };
  })
