Commit 391cae85 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

proxy auth stub

parent 36b7c99f
...@@ -11,7 +11,9 @@ import javax.inject.Singleton; ...@@ -11,7 +11,9 @@ import javax.inject.Singleton;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Optional; import java.util.Optional;
@Singleton @Singleton
...@@ -41,4 +43,17 @@ public class UtilResource ...@@ -41,4 +43,17 @@ public class UtilResource
} }
return responseBuilder.build(); return responseBuilder.build();
} }
//todo: cleanup
@GET
@Path("/auth")
public Response auth(@Auth User user)
{
String jsRedirect = "<script type=\"text/javascript\">\n" +
"<!--\n" +
"window.location = \"/page/#/tasks\"\n" +
"//-->\n" +
"</script>";
return Response.ok().entity(jsRedirect).header(HttpHeaders.CONTENT_TYPE, "text/html").build();
}
} }
(function(){ (function(){
angular.module('ctfApp').controller('LoginController', angular.module('ctfApp').controller('LoginController',
['$scope', '$rootScope', '$location', 'AuthenticationService', ['$scope', '$rootScope', '$location', 'AuthenticationService', '$window',
function ($scope, $rootScope, $location, AuthenticationService) { function ($scope, $rootScope, $location, AuthenticationService, $window) {
// reset login status // reset login status
AuthenticationService.clearCredentials(); AuthenticationService.clearCredentials();
...@@ -9,9 +9,13 @@ ...@@ -9,9 +9,13 @@
$scope.dataLoading = true; $scope.dataLoading = true;
AuthenticationService.login($scope.username, $scope.password, function(response) { AuthenticationService.login($scope.username, $scope.password, function(response) {
if(response.status == 200) { if(response.status == 200) {
AuthenticationService.setCredentials($scope.username, $scope.password, response.team); //todo: put credentials here
$('.title').html($scope.username+'@<b>capture-the-flAGH-2016</b>:~$'); $window.location.href = "http://gpietrus1:gpietrus@localhost:8080/api/v1/auth";
$location.path('/'); //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('/');
} else { } else {
$scope.error = response.message; $scope.error = response.message;
$scope.dataLoading = false; $scope.dataLoading = false;
......
...@@ -85,9 +85,10 @@ ...@@ -85,9 +85,10 @@
$rootScope.$on('$locationChangeStart', function (event, next, current) { $rootScope.$on('$locationChangeStart', function (event, next, current) {
// redirect to login page if not logged in // redirect to login page if not logged in
console.log('Globale', $rootScope.globals); console.log('Globale', $rootScope.globals);
if ($location.path() !== '/login' && !$rootScope.globals.currentUser) { //todo: commented temporarily
$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