-
Notifications
You must be signed in to change notification settings - Fork 625
Auth.$bindTo implementation. #474
Conversation
Users should be allowed to bind to a deep property (i.e. 'obj.authData' instead of just 'authData'). Should be easily accomplished with $parse service
|
I added an example for how I envision the $bindTo function being used, and an associated build step. |
Previously redirects were causing the reloaded page to default back to popup mode. This solves that by saving the current choice in the url.
|
Prior to the 0.9.0 release, we provided an @katowulf - what are your thoughts here? |
|
I'd prefer to see this as a service and not part of the core. I think both of you have made great points here and in our technical discussions and I still agree with our decision to take this out. |
|
The advantage of Users could certainly implement their own version of this pretty easily. ref.onAuth(function(authData){
scope.$apply(function(){
scope.auth = authData
});
});The potential downfall there however, is that the Firebase reference is long lived and is now holding a reference to scope, so that scope can't be garbage collected. You could see how this could get messy inside a paginated I'm curious why you argued to remove the |
|
Didn't realize that $onAuth() isn't triggering a digest. That we should definitely fix, which should make the rest of this much simpler. The reason auth was decided against is that it was essentially creating a global variable and all the baggage that comes with that (additionally there was no way to tell if it changed unless one So essentially, $onAuth() should work in a real-time, event-driven manner, vs the old |
|
Here is the use case I am trying to enable. Controller: ref.$bindTo($scope,'authData');HTML: <button ... ng-hide="authData.provider=='twitter'">Twitter</button>
<!-- or if you've implemented some additional info in your custom auth -->
<div ng-repeat="message in messages">
<span>{{message.contents}}</span>
<button ng-show="authData.isModerator">Moderate this post...</button>
</div> |
|
The current implementation also doesn't play nice with the |
|
@al-the-x please submit a new issue for that; will get it added; has nothing to do with Auth.$bindTo and won't get fixed here (as evidenced by the fact that this is the second comment added to this thread on that topic). |
|
Lots of good stuff in this thread. @katowulf went ahead updated Closing this PR. |
|
Great job! |
Just an idea, but it seems like it would be helpful to bind authentication state to scope.
This mimics the
$bindTo()method used for data binding.I haven't tested it at all, submitted solely for your consideration.