diff options
| -rw-r--r-- | client/index.html | 3 | ||||
| -rw-r--r-- | client/js/app.js | 3 | ||||
| l--------- | client/js/controllers/.#status.js | 1 | ||||
| -rw-r--r-- | client/js/controllers/login.js | 16 | ||||
| -rw-r--r-- | client/js/controllers/status.js | 11 | ||||
| -rw-r--r-- | client/js/services/Identity.js | 77 | ||||
| -rw-r--r-- | client/js/services/Image.js | 21 | ||||
| -rw-r--r-- | client/partials/login.html | 2 | ||||
| -rw-r--r-- | client/partials/nav.html | 3 | ||||
| -rw-r--r-- | client/vendors/angularjs/angular-cookies.min.js | 9 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/Test/genTokenOptionsTest.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/composer.phar | bin | 1514291 -> 1514291 bytes | |||
| -rw-r--r--[-rwxr-xr-x] | server/core/App.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/core/CoreInterface.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/core/Identity.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/core/LibOverride/genTokenOptions.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/index.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/init.php | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | server/vendor/justinrainbow/json-schema/bin/validate-json | 0 |
19 files changed, 119 insertions, 27 deletions
diff --git a/client/index.html b/client/index.html index ab5f00f..26430f9 100644 --- a/client/index.html +++ b/client/index.html @@ -61,7 +61,7 @@ <!-- Include JQuery --> <script src="./vendors/jquery/jquery-2.2.0.min.js"></script> - + <!-- Include Bootstrap --> <script src="./vendors/bootstrap/js/bootstrap.min.js"></script> @@ -69,6 +69,7 @@ <script src="./vendors/angularjs/angular.min.js"></script> <script src="./vendors/angularjs/angular-route.min.js"></script> <script src="./vendors/angularjs/angular-sanitize.min.js"></script> + <script src="./vendors/angularjs/angular-cookies.min.js"></script> <script src="./js/app.js"></script> <!-- Include services --> diff --git a/client/js/app.js b/client/js/app.js index 90fae89..e2d5b9b 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -3,7 +3,7 @@ * The main app module instance * @type angular.module.angular-1_3_6_L1749.moduleInstance */ -var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize']); +var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize', 'ngCookies']); /** * Configure routeProvider @@ -29,6 +29,5 @@ mainApp.config(['$routeProvider', function($routeProvider){ */ mainApp.config(['$httpProvider', function($httpProvider){ $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - }]); diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js new file mode 120000 index 0000000..e6c258f --- /dev/null +++ b/client/js/controllers/.#status.js @@ -0,0 +1 @@ +loic@Manzerbredes.home.30343:1455008378
\ No newline at end of file diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 6358a6d..829fc1d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -9,14 +9,20 @@ */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); + // Check for login and define default states + if(!Identity.isAlreadyLogin()){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + } + $scope.$on('logoutEvent', function(){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + }); + $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); - $('#loginButton').click(function(){ - + $scope.loginAction=function(){ + // Begin login state for template $('#loginButton').hide(); $('#loadingLoginButton').show(); @@ -49,6 +55,6 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s // Try to login Identity.login(username, password, projectname, responseCallback); - }); + }; }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 2930e34..6bc602a 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -6,9 +6,14 @@ * @param {$scope} $scope The $scope service from angular * @param {Identity} The Identity service */ -mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) +mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { $scope.profile=Identity.profile; - - + + $scope.logout=function(){ + Identity.logout(); + $rootScope.$broadcast('logoutEvent'); + + }; + }]); diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 4c8919c..d96b3ab 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,5 +1,5 @@ -mainApp.factory('Identity',[ '$http', function($http){ +mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ /* Create profile structure to store informations * about current session @@ -9,7 +9,72 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.projectname=null; profile.token=null; +/* var tokenFragment=9; + + var saveTokenInCookies=function(){ + var i=0; + var currentStart=0; + var currentEnd=parseInt(profile.token.length/tokenFragment); + var facto=currentEnd; + + alert("current ren" + currentEnd); + for(i=0;i<tokenFragment-1;i++){ + + $cookies.put("token-"+i, profile.token.substring(currentStart, currentEnd)); + + + currentStart=currentEnd+1; + currentEnd=currentEnd+facto; + + + } + $cookies.put("token-"+(i+1), profile.token.substring(currentEnd, profile.token.length)); + }; + + var loadTokenInCookies=function(){ + var i=0; + + profile.token=$cookies.get("token-0"); + for(i=1;i<tokenFragment;i++){ + + profile.token=profile.token+$cookies.get("token-"+i) + + + + + } + + + };*/ + + + + var saveCookieForSession=function(){ + $cookies.putObject('profile', 5); + //saveTokenInCookies(); + }; + + + + + + var isAlreadyLogin=function(){ + var profileInCookie=$cookies.getObject('profile'); + console.log(profileInCookie); + + if(typeof profileInCookie !== 'undefined'){ + angular.extend(profile, profileInCookie); + return true; + } + + return false; + } + + var logout=function(){ + $cookies.remove('profile'); + } + /** * * @param {string} response The response to parse @@ -17,6 +82,7 @@ mainApp.factory('Identity',[ '$http', function($http){ * @returns {requestParserResult} Formated data */ var parseLoginAnswer=function(response, failedToSendRequest){ + var requestParserResult={}; requestParserResult.status=1; @@ -24,7 +90,8 @@ mainApp.factory('Identity',[ '$http', function($http){ if (typeof response.data.token !== 'undefined') { requestParserResult.status=0; - profile.token=response.data.token; + profile.token=response.data.token; + saveCookieForSession(); } else if(failedToSendRequest){ requestParserResult.failReason="Failed to send request"; @@ -48,7 +115,7 @@ mainApp.factory('Identity',[ '$http', function($http){ * @param {function} function to call when data is avalaible */ var login=function(username, password,projectname, callback){ - + // Set profile information (early) profile.username=username; profile.projectname=projectname; @@ -67,7 +134,9 @@ mainApp.factory('Identity',[ '$http', function($http){ // Return services objects return { login: login, - profile: profile + profile: profile, + isAlreadyLogin: isAlreadyLogin, + logout:logout }; diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 4cb3590..23b33a8 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -1,24 +1,27 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ - var httpResponse; - var uploadImage=function(image){ + + var parseUploadImageAnswer=function(response, failedToSendRequest){ }; - var parseUploadImageRequest=function(){ + + var getImages=function(callback){ + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.profile.token, "task" : "Image"})); + + }; - var getResponse=function(){ - return parseUploadImageRequest(httpResponse); - }; - + + // Return services objects return { - uploadImage: uploadImage, - getResponse: getResponse + uploadImage: uploadImage }; diff --git a/client/partials/login.html b/client/partials/login.html index cd7d9ec..7519a83 100644 --- a/client/partials/login.html +++ b/client/partials/login.html @@ -34,7 +34,7 @@ <!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>--> <button class="btn btn-lg btn-warning btn-block" id="loadingLoginButton"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Loading...</button> <div class="alert alert-danger text-center" role="alert" id="failedToLoginAlert"><b>Failed to login</b></b><br />{{ failReason }}</div> - <a href="#" class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="processForm()">Login</a> + <a href="#" class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="loginAction()">Login</a> </div> </div> </div> diff --git a/client/partials/nav.html b/client/partials/nav.html index 7c34174..3c72844 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -32,8 +32,7 @@ <li><a href="#">Informations</a></li> <li><a href="#">Settings</a></li> <li role="separator" class="divider"></li> - <li><a href="#myModal" data-toggle="modal">Logout</a> - </li> + <li><a href="#" ng-click="logout()">Logout</a></li> </ul> </li> </ul> diff --git a/client/vendors/angularjs/angular-cookies.min.js b/client/vendors/angularjs/angular-cookies.min.js new file mode 100644 index 0000000..d0f126a --- /dev/null +++ b/client/vendors/angularjs/angular-cookies.min.js @@ -0,0 +1,9 @@ +/* + AngularJS v1.5.0 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(p,c,n){'use strict';function l(b,a,g){var d=g.baseHref(),k=b[0];return function(b,e,f){var g,h;f=f||{};h=f.expires;g=c.isDefined(f.path)?f.path:d;c.isUndefined(e)&&(h="Thu, 01 Jan 1970 00:00:00 GMT",e="");c.isString(h)&&(h=new Date(h));e=encodeURIComponent(b)+"="+encodeURIComponent(e);e=e+(g?";path="+g:"")+(f.domain?";domain="+f.domain:"");e+=h?";expires="+h.toUTCString():"";e+=f.secure?";secure":"";f=e.length+1;4096<f&&a.warn("Cookie '"+b+"' possibly not set or overflowed because it was too large ("+ +f+" > 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,n,k?c.extend({},b,k):b)}}}]}]);c.module("ngCookies").factory("$cookieStore", +["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,c){b.putObject(a,c)},remove:function(a){b.remove(a)}}}]);l.$inject=["$document","$log","$browser"];c.module("ngCookies").provider("$$cookieWriter",function(){this.$get=l})})(window,window.angular); +//# sourceMappingURL=angular-cookies.min.js.map diff --git a/server/Test/genTokenOptionsTest.php b/server/Test/genTokenOptionsTest.php index 54c22d2..54c22d2 100755..100644 --- a/server/Test/genTokenOptionsTest.php +++ b/server/Test/genTokenOptionsTest.php diff --git a/server/composer.phar b/server/composer.phar Binary files differindex 0281237..0281237 100755..100644 --- a/server/composer.phar +++ b/server/composer.phar diff --git a/server/core/App.php b/server/core/App.php index dafdaad..dafdaad 100755..100644 --- a/server/core/App.php +++ b/server/core/App.php diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php index ed0d959..ed0d959 100755..100644 --- a/server/core/CoreInterface.php +++ b/server/core/CoreInterface.php diff --git a/server/core/Identity.php b/server/core/Identity.php index 7b6293c..7b6293c 100755..100644 --- a/server/core/Identity.php +++ b/server/core/Identity.php diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 58b87c1..58b87c1 100755..100644 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php diff --git a/server/index.php b/server/index.php index 166e82e..166e82e 100755..100644 --- a/server/index.php +++ b/server/index.php diff --git a/server/init.php b/server/init.php index cf08523..cf08523 100755..100644 --- a/server/init.php +++ b/server/init.php diff --git a/server/vendor/justinrainbow/json-schema/bin/validate-json b/server/vendor/justinrainbow/json-schema/bin/validate-json index e93d53a..e93d53a 100755..100644 --- a/server/vendor/justinrainbow/json-schema/bin/validate-json +++ b/server/vendor/justinrainbow/json-schema/bin/validate-json |
