|
1 |
| -zenergyApp.controller("registerPageController", ["$scope", "$http", "$httpParamSerializerJQLike", "tokenService", "$window", function ($scope, $http, $httpParamSerializerJQLike, tokenService, $window) { |
2 |
| - |
3 |
| - $scope.user = { mail: '', password: '', passwordBis: '', firstName :'', lastName:'', adr1:'', adr2:'', pc:'', town:'', phone:''}; |
| 1 | +zenergyApp.controller("registerPageController",["$scope","$http", function($scope, $http){ |
| 2 | + |
| 3 | + $scope.user = {mail: '', password: '', passwordBis: '', lastName:'', firstName:'', adr1:'', adr2:'', pc:'', town:'', phone:''}; |
4 | 4 | $scope.hasError = false;
|
5 |
| - $scope.signIn = function () { |
| 5 | + $scope.register = function () { |
6 | 6 | var response = $http({
|
7 | 7 | url: 'api/Account/register',
|
8 | 8 | method: 'POST',
|
9 |
| - data: $httpParamSerializerJQLike({ grant_type: 'password', username: $scope.user.mail, password: $scope.user.password }), |
10 |
| - //data: $httpParamSerializerJQLike({ grant_type: 'password', username: $scope.user.mail, password: CryptoJS.MD5($scope.user.password).toString() }), |
| 9 | + data: $httpParamSerializerJQLike({ userId: 1, password: CryptoJS.MD5($scope.user.password).toString(), lastName: $scope.user.lastName, firstName: $scope.user.firstName, adr1: $scope.user.adr1, adr2: $scope.user.adr2, pc: $scope.user.pc, town: $scope.user.town, mail: $scope.user.mail, phone: $scope.user.phone }), |
| 10 | + // password: CryptoJS.MD5($scope.user.password).toString() }), |
11 | 11 | headers: {
|
12 |
| - 'Content-Type': 'application/x-www-form-urlencoded' |
| 12 | + 'Content-Type': 'application/json' |
13 | 13 | }
|
14 | 14 | }).then(function successCallback(response) {
|
15 | 15 | $scope.hasError = false;
|
16 | 16 | tokenService.saveToken(response.data.access_token, response.data.userName);
|
17 |
| - window.location.replace("/Home"); |
| 17 | + window.location.replace("/Login"); |
18 | 18 | }, function errorCallback(response) {
|
19 | 19 | $scope.hasError = true;
|
20 | 20 | tokenService.deleteToken();
|
|
0 commit comments