Commit 35031bf8 authored by Evren Kutar's avatar Evren Kutar

error message on login error

parent 059f199d
...@@ -35,7 +35,11 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener ...@@ -35,7 +35,11 @@ auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Gener
$scope.onSubmit = function (form) { $scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate'); $scope.$broadcast('schemaFormValidate');
if (form.$valid) { if (form.$valid) {
LoginService.login($scope.url, $scope.model); LoginService.login($scope.url, $scope.model)
.error(function(data){
$scope.message = data.title;
debugger;
})
} }
else { else {
console.log("not valid"); console.log("not valid");
......
...@@ -19,14 +19,13 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook ...@@ -19,14 +19,13 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
.success(function (data, status, headers, config) { .success(function (data, status, headers, config) {
//$window.sessionStorage.token = data.token; //$window.sessionStorage.token = data.token;
$rootScope.loggedInUser = true; $rootScope.loggedInUser = true;
$location.path("/dashboard");
}) })
.error(function (data, status, headers, config) { .error(function (data, status, headers, config) {
// Erase the token if the user fails to log in // Erase the token if the user fails to log in
//delete $window.sessionStorage.token; //delete $window.sessionStorage.token;
// Handle login errors here // Handle login errors here
$scope.message = 'Error: Invalid user or password'; return data;
}); });
//.then(function (res) { //.then(function (res) {
// $log.info(res.data[0]); // $log.info(res.data[0]);
......
<div ng-app="zaerp.auth"> <div ng-app="zaerp.auth">
<div class="col-md-6"> <div class="col-md-6">
<h1>Ulakbüs Login Form</h1> <h1>Ulakbüs Login Form</h1>
<span class="label label-warning">{{message}}</span>
<form name="loginForm" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(loginForm)"></form> <form name="loginForm" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(loginForm)"></form>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -27,9 +27,9 @@ app.config(['$httpProvider', function ($httpProvider) { ...@@ -27,9 +27,9 @@ app.config(['$httpProvider', function ($httpProvider) {
if(response.data.is_login===true){ if(response.data.is_login===true){
$rootScope.loggedInUser = response.data.is_login; $rootScope.loggedInUser = response.data.is_login;
$location.replace(); $location.replace();
//if($location.path()==="/login"){ if($location.path()==="/login"){
// $location.path("/dashboard"); $location.path("/dashboard");
//} }
} }
if(response.data.screen) { if(response.data.screen) {
$location.path(response.data.screen); $location.path(response.data.screen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment