Commit 8a3d41fd authored by Antek Grzanka's avatar Antek Grzanka

Fixed AUTH issues, now it works flawlessly on Chrome, almost flawlessly on FF…

Fixed AUTH issues, now it works flawlessly on Chrome, almost flawlessly on FF and somehow bad on Safari. But works.
parent a78d14fc
......@@ -51,9 +51,9 @@ public class UtilResource
{
String jsRedirect = "<script type=\"text/javascript\">\n" +
"<!--\n" +
"window.location = \"/page/#/tasks\"\n" +
"window.location = \"http://\" + window.location.host + \"/page\"\n" +
"//-->\n" +
"</script>";
return Response.ok().entity(jsRedirect).header(HttpHeaders.CONTENT_TYPE, "text/html").build();
return Response.ok().entity(jsRedirect).header(HttpHeaders.CONTENT_TYPE, "text/html").header(HttpHeaders.WWW_AUTHENTICATE, "Basic").build();
}
}
......@@ -9,15 +9,13 @@
$scope.dataLoading = true;
AuthenticationService.login($scope.username, $scope.password, function(response) {
if(response.status == 200) {
//todo: put credentials here
$window.location.href = "http://gpietrus1:gpietrus@localhost:8080/api/v1/auth";
//todo: commeneted temporarily
// $window.location.href = "http://gpietrus1:gpietrus@localhost:8080/api/v1/auth";
// AuthenticationService.setCredentials($scope.username, $scope.password, response.team);
// $('.title').html($scope.username+'@<b>capture-the-flAGH-2016</b>:~$');
// $location.path('/');
$('.title').html($scope.username+'@<b>capture-the-flAGH-2016</b>:~$');
$location.path('/');
AuthenticationService.setCredentials($scope.username, $scope.password, response.team);
// redirect to additional external auth point
$window.location.href = "http://"+$scope.username+":"+$scope.password+"@localhost:8080/api/v1/auth";
} else {
$scope.error = response.message;
Materialize.toast('Błąd logowania! Spróbuj jeszcze raz.', 5000 ,'toast-error');
$scope.dataLoading = false;
}
});
......
......@@ -7,9 +7,8 @@
$scope.user = $rootScope.globals && $rootScope.globals.currentUser ? $rootScope.globals.currentUser.username : undefined;
$scope.logout = function(){
AuthenticationService.logout(function(data){
console.log("Logged you out... i guess...", data);
$('.title').html('guest@<b>capture-the-flAGH-2016</b>:~$');
AuthenticationService.logout(function(data){
$location.path('/');
});
};
......
......@@ -85,10 +85,9 @@
$rootScope.$on('$locationChangeStart', function (event, next, current) {
// redirect to login page if not logged in
console.log('Globale', $rootScope.globals);
//todo: commented temporarily
// if ($location.path() !== '/login' && !$rootScope.globals.currentUser) {
// $location.path('/login');
// }
if ($location.path() !== '/login' && !$rootScope.globals.currentUser) {
$location.path('/login');
}
});
}]);
......
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