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

Merge fixes - aligining to deleted endpoint.

parent e986186f
(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;
return {
......@@ -28,10 +28,17 @@
},
getMySolutions: function(callback){
$http.get('http://' + AppSettings.apiAddress + '/solutions/my').
success(function(data) {
if (callback) callback(data);
});
var result;
if (!scores){
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){
......
......@@ -5,6 +5,8 @@
return {
team: $cookieStore.get('teamname'),
/**
* Login user.
* @param username
......@@ -19,6 +21,7 @@
.then(function (response) {
console.debug("RESPONSE", response);
response.team = response.data.teamName;
$cookieStore.put('teamname', response.team);
callback(response);
}, function(response) {
callback(response);
......@@ -72,9 +75,19 @@
clearCredentials: function () {
$rootScope.globals = {};
this.team = undefined;
$cookieStore.remove('globals');
$cookieStore.remove('team');
$http.defaults.headers.common.Authorization = 'Basic ';
},
setTeamname: function(team){
this.team = team;
},
getTeamname: function(){
return this.team;
}
};
......
......@@ -75,7 +75,7 @@
</div>
<div class="col s12 m4" style="text-align:center">
<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>
</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