This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit b6a809a8ee3398da60ebd7d83d8fcc9a33cabc7c Author: Yannick Martel <martel@©odelutin.com> Date: Mon Nov 24 17:42:35 2014 +0100 Fix way to pass login/password during login Add constant as config for services URL --- .../src/main/webapp/js/coselmar-constants.js | 3 +++ coselmar-ui/src/main/webapp/index.html | 31 +++++++++++----------- .../src/main/webapp/js/coselmar-constants.js | 3 +++ .../src/main/webapp/js/coselmar-controllers.js | 1 + .../src/main/webapp/js/coselmar-services.js | 9 +++---- .../src/main/webapp/js/coselmar-user-services.js | 24 ++++++++++++----- 6 files changed, 44 insertions(+), 27 deletions(-) diff --git a/coselmar-bundle/src/main/webapp/js/coselmar-constants.js b/coselmar-bundle/src/main/webapp/js/coselmar-constants.js new file mode 100644 index 0000000..9b21f5e --- /dev/null +++ b/coselmar-bundle/src/main/webapp/js/coselmar-constants.js @@ -0,0 +1,3 @@ +coselmarApp.constant('coselmar-config', { + BASE_URL : "v1" +}); \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index 1642334..e6f8235 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -24,21 +24,22 @@ <html ng-app="coselmarApp" ng-controller="HomeCtrl"> <head> - <link rel="stylesheet" href="nuiton-js/bootstrap.css"> - <link rel="stylesheet" href="css/coselmar.css"> - <script src="nuiton-js/jquery.js"></script> - <script src="nuiton-js/angular.js"></script> - <script src="nuiton-js/angular-route.js"></script> - <script src="nuiton-js/angular-resource.js"></script> - <script src="nuiton-js/angular.js"></script> - <script src="nuiton-js/angular-messages.js"></script> - <script src="nuiton-js/angular-ui-bootstrap.js"></script> - <script src="nuiton-js/bootstrap.js"></script> - <script src="js/angular-jwt.js"></script> - <script src="js/coselmar.js"></script> - <script src="js/coselmar-controllers.js"></script> - <script src="js/coselmar-services.js"></script> - <script src="js/coselmar-user-services.js"></script> + <link rel="stylesheet" href="nuiton-js/bootstrap.css"> + <link rel="stylesheet" href="css/coselmar.css"> + <script src="nuiton-js/jquery.js"></script> + <script src="nuiton-js/angular.js"></script> + <script src="nuiton-js/angular-route.js"></script> + <script src="nuiton-js/angular-resource.js"></script> + <script src="nuiton-js/angular.js"></script> + <script src="nuiton-js/angular-messages.js"></script> + <script src="nuiton-js/angular-ui-bootstrap.js"></script> + <script src="nuiton-js/bootstrap.js"></script> + <script src="js/angular-jwt.js"></script> + <script src="js/coselmar.js"></script> + <script src="js/coselmar-constants.js"></script> + <script src="js/coselmar-controllers.js"></script> + <script src="js/coselmar-services.js"></script> + <script src="js/coselmar-user-services.js"></script> </head> <body> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-constants.js b/coselmar-ui/src/main/webapp/js/coselmar-constants.js new file mode 100644 index 0000000..a56b911 --- /dev/null +++ b/coselmar-ui/src/main/webapp/js/coselmar-constants.js @@ -0,0 +1,3 @@ +coselmarApp.constant('coselmar-config', { + BASE_URL : "http://localhost:8081/services/v1" +}); \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 7c61138..0665085 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -30,6 +30,7 @@ coselmarControllers.controller("HomeCtrl", ['$scope', '$http', '$location', 'use var jwtToken = localStorage.getItem('coselmar-jwt'); if (jwtToken && !jwtHelper.isTokenExpired(jwtToken)) { $scope.currentUser = jwtHelper.decodeToken(jwtToken); + console.log($scope.currentUser); } //Just get the version from a file diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 26276cb..5b4d262 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -23,16 +23,15 @@ */ var coselmarServices = angular.module('coselmarServices', ['ngResource']); -coselmarServices.factory('documentService', ['$resource', function($resource){ - return new Document($resource); +coselmarServices.factory('documentService', ['$resource', 'coselmar-config', function($resource, coselmarConfig){ + return new Document($resource, coselmarConfig); }]); -function Document(resource){ +function Document(resource, config){ this.resource = resource; -// var baseURL = "http://localhost:8081/services/v1/documents"; - var baseURL = "v1/documents"; + var baseURL = config.BASE_URL + "/documents"; this.createDocument = function(metadata, file, scope){ diff --git a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js index a829b19..617ffcd 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-user-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-user-services.js @@ -21,17 +21,16 @@ * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ -coselmarServices.factory('userService', ['$resource', function($resource){ - return new User($resource); +coselmarServices.factory('userService', ['$resource', 'coselmar-config', function($resource, coselmarConfig){ + return new User($resource, coselmarConfig); }]); -function User(resource){ +function User(resource, config){ this.resource = resource; - var baseURL = "http://localhost:8081/services/v1/users"; -// var baseURL = "v1/users"; + var baseURL = config.BASE_URL + "/users"; this.createUser = function(user, successFunction, failFunction){ @@ -83,7 +82,18 @@ function User(resource){ this.login = function(mail, password, successFunction, failFunction){ - var userResource = resource(baseURL + "/login", {mail:'@mail', password:'@password'}, {'post' : {method: 'POST'}}); - userResource.post({'mail': mail, 'password': password}, successFunction, failFunction); + var credentials = $.param({ + 'mail' : mail, + 'password' : password + }); + + var userResource = resource(baseURL + "/login", null, { + 'post' : { + method: 'POST', + headers : { + 'Content-Type' : 'application/x-www-form-urlencoded' + }, + }}); + userResource.post(credentials, successFunction, failFunction); } }; \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.