login modal doesn't go away after successful login in angular-app

247 views
Skip to first unread message

Carl Youngblood

unread,
Jan 20, 2013, 10:06:57 PM1/20/13
to ang...@googlegroups.com
I'm trying to adapt the authentication from the angular sample app (https://github.com/angular-app/angular-app) to my own needs. I'm new to angular.

Anyhow, I am able to successfully login to my REST backend, but the login form doesn't disappear after that. Do I need to add something in AuthenticationService#login to refresh the view after successful login or something?

Thanks,
Carl

Jakub Kuchar

unread,
Jan 21, 2013, 2:05:09 AM1/21/13
to ang...@googlegroups.com, ca...@youngbloods.org
Have you implemented /current-user at the backend?

Dne pondělí, 21. ledna 2013 4:06:57 UTC+1 Carl Youngblood napsal(a):

Carl Youngblood

unread,
Jan 21, 2013, 3:27:26 AM1/21/13
to ang...@googlegroups.com
Yes. And if I manually remove the modal I can freely browse the protected web addresses after logging in with a valid user. It just doesn't hide the login form after successful login.


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
 
 

Jakub Kuchar

unread,
Jan 21, 2013, 3:38:26 AM1/21/13
to ang...@googlegroups.com, ca...@youngbloods.org
Hmm, strange , saying this because i have also used Authentication Service from angular-app and working properly. But maybe i took much more from angular-app than you. Have you taken loginForm directive, because it watching and hiding...

      $scope.$watch(AuthenticationService.isLoginRequired, function(value) {
        if ( value ) {
          $scope.showLogin($scope.getLoginReason());
        } else {
          $scope.hideLogin();
        }
      });





Dne pondělí, 21. ledna 2013 4:06:57 UTC+1 Carl Youngblood napsal(a):
I'm trying to adapt the authentication from the angular sample app (https://github.com/angular-app/angular-app) to my own needs. I'm new to angular.

Carl Youngblood

unread,
Jan 21, 2013, 3:41:32 AM1/21/13
to ang...@googlegroups.com
Strange that your code is different from mine there. That was how I fixed it. I had to add a $scope.hideLogin() if the login was successful. For some reason it's not in the angular-app code. While I'm at it, got any quick advice for how to make the login form accept enter to submit it rather than requiring a button click?


--

Jakub Kuchar

unread,
Jan 21, 2013, 4:14:53 AM1/21/13
to ang...@googlegroups.com, ca...@youngbloods.org
If I understood you correctly your doubts leads to my previous question check this out:

https://groups.google.com/forum/?fromgroups=#!topic/angular/R43Rn3HRkik

(resolving the promise AuthenticationService.requireAuthenticatedUser(); in your protected controller is needed) then login form pop-up automatically..




Dne pondělí, 21. ledna 2013 4:06:57 UTC+1 Carl Youngblood napsal(a):
I'm trying to adapt the authentication from the angular sample app (https://github.com/angular-app/angular-app) to my own needs. I'm new to angular.

Peter Bacon Darwin

unread,
Jan 21, 2013, 4:43:06 AM1/21/13
to ang...@googlegroups.com
@Carl - the button will not submit automatically because it is outside the form.  We added ng-submit to the form but it doesn't seem to be firing.  Will look into this.


--

Peter Bacon Darwin

unread,
Jan 21, 2013, 4:59:53 AM1/21/13
to ang...@googlegroups.com
@carl - actually the reason the ng-submit doesn't happen is because in the HTML spec it says:

if a form has has 2+ input fields and no buttons or input[type=submit] then hitting enter doesn't trigger submit

The login form has two inputs (email and password) and so ng-submit never gets triggered.  The easiest solution is to move the form outside the "modal-body" element so that the default button is inside it and so would be triggered when pressing enter.  It will push a fix.

Carl Youngblood

unread,
Jan 21, 2013, 5:28:16 AM1/21/13
to ang...@googlegroups.com
Thanks guys. One more problem. After successful login and now that I've figured out how to make the login modal disappear, it's not taking the user to the protected page that they clicked on. I can refresh the page manually to get there but right now it just leaves me on the page I was on when the login prompt came up. Is there something else I need to do after hiding the login to make the right page be displayed? Just to clarify, after successful login and refresh, these links display the protected content just fine.

Peter Bacon Darwin

unread,
Jan 21, 2013, 6:03:45 AM1/21/13
to ang...@googlegroups.com
Have you forked out repos?  Can you publish it?  It is pretty impossible to give you guidance without seeing what you are doing.
Reply all
Reply to author
Forward
0 new messages