Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a user already exists don't send to index. #86

Open
cleversprocket opened this issue Jun 30, 2014 · 1 comment
Open

If a user already exists don't send to index. #86

cleversprocket opened this issue Jun 30, 2014 · 1 comment

Comments

@cleversprocket
Copy link

When registering a new user and a 403 is returned because there is already one with the same name, they should not be sent to the index page but kept on the register page so they can try again.

Here's a quick solution. Let me know if there's a better one!:

//file: controllers.js
//...
.controller('RegisterCtrl',
//...
$scope.register = function () {
            Auth.register({
                username: $scope.username,
                password: $scope.password,
                role: $scope.role
            },
            function () {
                $location.path('/');
            },
            function (err) {
                $rootScope.error = err;
//If there is an error then stay on the register page
                if(err !== null) {
                    $location.path('/register');
                }
            });
        };
}]);
@fnakstad
Copy link
Owner

Excellent observation! Thank you so much.
I'd be happy to receive a PR for this since you've already solved it. If it's too much bother, let me know and I will make the changes myself :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants