Commit 7059ec63 authored by Antek Grzanka's avatar Antek Grzanka

Merge fixes - aligining to deleted endpoint.

parent e986186f
(function(){ (function(){
angular.module('ctfApp').factory('APIProvider', ['$http', 'AppSettings', function($http, AppSettings){ angular.module('ctfApp').factory('APIProvider', ['$http', 'AppSettings', 'AuthenticationService', function($http, AppSettings, AuthenticationService){
var tasks, teams, scores; var tasks, teams, scores;
return { return {
...@@ -28,10 +28,17 @@ ...@@ -28,10 +28,17 @@
}, },
getMySolutions: function(callback){ getMySolutions: function(callback){
$http.get('http://' + AppSettings.apiAddress + '/solutions/my'). var result;
success(function(data) { if (!scores){
if (callback) callback(data); this.getScores(function(data){
}); result = this.getMySolutions(callback);
}.bind(this));
}
else {
result = scores[AuthenticationService.getTeamname()];
}
console.debug("Result", result);
callback(result);
}, },
getTaskById: function(id, callback){ getTaskById: function(id, callback){
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
return { return {
team: $cookieStore.get('teamname'),
/** /**
* Login user. * Login user.
* @param username * @param username
...@@ -19,6 +21,7 @@ ...@@ -19,6 +21,7 @@
.then(function (response) { .then(function (response) {
console.debug("RESPONSE", response); console.debug("RESPONSE", response);
response.team = response.data.teamName; response.team = response.data.teamName;
$cookieStore.put('teamname', response.team);
callback(response); callback(response);
}, function(response) { }, function(response) {
callback(response); callback(response);
...@@ -72,9 +75,19 @@ ...@@ -72,9 +75,19 @@
clearCredentials: function () { clearCredentials: function () {
$rootScope.globals = {}; $rootScope.globals = {};
this.team = undefined;
$cookieStore.remove('globals'); $cookieStore.remove('globals');
$cookieStore.remove('team');
$http.defaults.headers.common.Authorization = 'Basic '; $http.defaults.headers.common.Authorization = 'Basic ';
},
setTeamname: function(team){
this.team = team;
},
getTeamname: function(){
return this.team;
} }
}; };
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
</div> </div>
<div class="col s12 m4" style="text-align:center"> <div class="col s12 m4" style="text-align:center">
<img class="responsive-img" src="http://lorempixel.com/400/300/"/> <img class="responsive-img" src="http://lorempixel.com/400/300/"/>
<a class="waves-effect waves-light btn" target="_blank" href="{{apiAddress}}/task/{{task.level}}" <a class="waves-effect waves-light btn" target="_blank" href="{{apiAddress}}/task/{{task.level}}/"
style="width:100%;margin-top:15px">Otwórz stronę z zadaniem</a> style="width:100%;margin-top:15px">Otwórz stronę z zadaniem</a>
</div> </div>
</div> </div>
......
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