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

Auth.currentUser() always posts when called? #79

Open
JeffreyCheng92 opened this issue Nov 8, 2015 · 0 comments
Open

Auth.currentUser() always posts when called? #79

JeffreyCheng92 opened this issue Nov 8, 2015 · 0 comments

Comments

@JeffreyCheng92
Copy link

I have the onEnter passed into my router but Auth.currentUser() makes a post to users/sign_on.json even when I dont want it to. I just made a get request for the register page and it already tries to log in.. I checked Auth.currentUser() in the console and it returns a promise with a status of 0 and nothing else.

.state('register', {
            url: '/register',
            templateUrl: 'auth/register.html',
            controller: 'AuthCtrl',
            onEnter: ['$state', 'Auth', function($state, Auth) {
              Auth.currentUser().then(function (){
                // $state.go('home');
              }, function(error) {
                console.log(error)
              })
            }]

This is the post request made automatically after I make a get request for the user registration page.

Started POST "/users/sign_in.json" for ::1 at 2015-11-07 18:01:46 -0800
Processing by Devise::SessionsController#create as JSON
Parameters: {"user"=>{}, "session"=>{"user"=>{}}}
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)

I think a solution would be for me to user Auth._currentUser which returns null but the docs say just to rely on the Auth.currentUser() promise instead..

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

No branches or pull requests

1 participant