app.controller('QuotationCheckCtrl', function($scope, $http, Auth, $window, user, $location) { //login with id and password for a account $scope.doTokenLogin = function() { // Login var req = { method: 'POST', url: '/user/tokenlogin/' + $routeParams['token'], } $http(req).then(function(response) { user.refresh().then(function(user) { //if status true send to the dashboard page if(response.data.status){ $scope.user = response.data.data; // Redirect to the correct page $location.path('/'); setTimeout(function() { window.dispatchEvent(new Event('resize')) }, 500); } //if status false give error message else{ //wrong data swal("Helaas", "Ongeldige login", "error"); } }); }); } });