I've tested this plunker and it gives User Authenticate no mater wich input you send, even if inputs are empty. Did you manage to build a project based in ui-router, local storage, restangular? Is it public to give it a look? I need to give fast timing to shift a project with nested data from using external api with restangular to localStorage instead of the api, and I'm not able to find working examples or confirmations that it would work :) Thanks in advance!
El jueves, 23 de enero de 2014, 0:00:57 (UTC+1), Brad McAlister escribió: > > I got most of my issues worked out. Here's a new plunker that works: > http://plnkr.co/edit/SVV1nsdUOWiBVdyAF99F?p=preview > > > > On Tuesday, January 21, 2014 9:23:36 AM UTC-6, Brad McAlister wrote: >> >> OK. I have a new plunker that's adjusted a bit. >> http://plnkr.co/edit/0xeB29bcVjPpFJ8tjk0a?p=preview >> >> I thought this approach was correct but I was having issues working it >> out. I managed to get it working for the most part but the part that I'm >> still struggling with is that once you login and the promise is returned it >> doesn't set the state to the new route. It looks like it's not doing >> anything when the promise is returned except console.log(). I'm getting >> data back from a mongolab call and trying to bind it to the template with >> $scope.MongoData and it's not updating the template but will console.log >> the $scope.MongoData. Also, I'm trying to change the value of >> $scope.LoginStatus while we wait on the promise to return and it's not >> updating the template either. So it looks like there's something not quite >> right with anything dynamic when the promise returns. >> >> Does that make sense? >> >> On Tuesday, January 21, 2014 3:51:13 AM UTC-6, Alon Nisser wrote: >>> >>> Can you specify what is the exact problem with this approach? >>> This approach is generally correct. >>> >>> But from looking at your code I think the check if isAuthentecated would >>> fail since the service doesn't run the check. I think you should add a >>> `setter` and `getter` methods to this service, enabling you to run the >>> check with setter in the "run" phase of angular, and then the onChangeStart >>> event can check the getter to see if the use isAuthenticated or nor >>> >>> On Monday, January 20, 2014 7:21:06 PM UTC+2, Brad McAlister wrote: >>>> >>>> I'm trying to figure out how to have my app check to see if a user is >>>> logged in and if so route them directly to the 'home' page and if not >>>> route >>>> the to the login page. I need the local storage data to be available >>>> across >>>> controllers so it seems like a service is the best fit for this. However, >>>> I'm having issues figuring out exactly how to do this with my current >>>> setup. >>>> >>>> This is the idea: >>>> User logs in, auth info is stored in local storage object, they are >>>> redirected to 'home' page >>>> User closes browser and returns later, app check local storage to see >>>> if auth info exists >>>> If auth info exists user is automatically redirected to 'home' >>>> If auth info doesn't exist user is directed to login page >>>> >>>> There will be more views and controllers than just login and home and I >>>> will need local storage object accessible across all of them. >>>> >>>> I thought I could use one service to handle the auth in either >>>> situation but I cant' quite figure it out. >>>> >>>> Plunker: http://plnkr.co/edit/ZmrEiYRTB16J7LIEzR4n?p=preview >>>> >>>> Thanks. >>>> >>>> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
