signin.js 671 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. /* Controllers */
  3. // signin controller
  4. app.controller('SigninFormController', ['$scope', '$http', '$state', function($scope, $http, $state) {
  5. $scope.user = {};
  6. $scope.authError = null;
  7. $scope.login = function() {
  8. $scope.authError = null;
  9. // Try to login
  10. $http.post('api/login', {email: $scope.user.email, password: $scope.user.password})
  11. .then(function(response) {
  12. if ( !response.data.user ) {
  13. $scope.authError = 'Email or Password not right';
  14. }else{
  15. $state.go('app.dashboard-v1');
  16. }
  17. }, function(x) {
  18. $scope.authError = 'Server Error';
  19. });
  20. };
  21. }])
  22. ;