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
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
LoginService.login($scope.url, $scope.model);
LoginService.login($scope.url, $scope.model)
.error(function(data){
$scope.message = data.title;
debugger;
})
}
else {
console.log("not valid");
......
......@@ -19,14 +19,13 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
.success(function (data, status, headers, config) {
//$window.sessionStorage.token = data.token;
$rootScope.loggedInUser = true;
$location.path("/dashboard");
})
.error(function (data, status, headers, config) {
// Erase the token if the user fails to log in
//delete $window.sessionStorage.token;
// Handle login errors here
$scope.message = 'Error: Invalid user or password';
return data;
});
//.then(function (res) {
// $log.info(res.data[0]);
......
<div ng-app="zaerp.auth">
<div class="col-md-6">
<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>
</div>
</div>
\ No newline at end of file
......@@ -27,9 +27,9 @@ app.config(['$httpProvider', function ($httpProvider) {
if(response.data.is_login===true){
$rootScope.loggedInUser = response.data.is_login;
$location.replace();
//if($location.path()==="/login"){
// $location.path("/dashboard");
//}
if($location.path()==="/login"){
$location.path("/dashboard");
}
}
if(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