Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshes committed Apr 23, 2016
1 parent b6cf577 commit 4720a81
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions app/static/js/signUpController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,23 @@ angular.module('WishList').controller('SignUpController',['$scope','$location','

$scope.signUp = function () {
APIService.signUpUser($scope.firstname,$scope.lastname,$scope.username,$scope.password,$scope.email)
.then(function (data) {
if(data.message=="Success"){
APIService.loginUser($scope.email,$scope.password)
.then(function (data){
if (data.data.status="logged"){
$cookies.put('loggedIn' , true);
$cookies.put('token' , data.data.token);
$cookies.put('userId', data.data.id);
$cookies.put('userName' , data.data.username);
$location.path('/home');
$scope.disabled = false;
$scope.signUpForm = {};
}
})
.catch(function (err) {
$scope.errorMessage = "Error signing up";
.then(function () {
APIService.loginUser($scope.email,$scope.password)
.then(function (data){
if (data.data.status="logged"){
$cookies.put('loggedIn' , true);
$cookies.put('token' , data.data.token);
$cookies.put('userId', data.data.id);
$cookies.put('userName' , data.data.username);
$location.path('/home');
$scope.disabled = false;
$scope.signUpForm = {};
});
}
else{
$scope.errorMessage = "Email already exists in system";
}
}
})
.catch(function (err) {
$scope.errorMessage = "Error signing up";
$scope.signUpForm = {};
});
})
.catch(function(err){
$scope.errorMessage = "Email already exists in system";
});
};
}]);

0 comments on commit 4720a81

Please sign in to comment.