FirebaseExtended / angularfire

AngularJS bindings for Firebase
MIT License
2.73k stars 632 forks source link

feat(auth): Add ability to link user with email credentials to current user #932

Closed idanen closed 4 years ago

idanen commented 7 years ago

Description

Adding the ability to link a user to a new user with email and password.

Code sample

angular.module('some-module', ['firebase'])
  .controller('MyCtrl', function MyCtrl($fireabseAuth) {
    this.authObj = $firebaseAuth();
    // ... Assuming user logged in somehow. Anonymously, or with other credentials
    this.user = this.authObj.$getAuth();

    // ... other logic ...

    // This could be linked to some `ng-click` for example
    this.linkUser = function (email, password) {
        this.authObj.$linkUser(email, password)
            .then(function (authData) {
                // This will not trigger a `$digest`, so do so if needed using `$timeout`, `$scope.$apply` or whatever suits you.
                this.user = authData;
            }.bind(this));
    };

    // Another way to get the user: listening to `$onAuthStateChanged`
    this.authObj.$onAuthStateChanged(function(firebaseUser) {
      if (firebaseUser) {
        console.log("Signed in as:", firebaseUser.uid);
        this.user = firebaseUser;
      } else {
        console.log("Signed out");
        this.user = undefined;
      }
    });
  });

Add the $linkUser method. #764

googlebot commented 7 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

googlebot commented 7 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

coveralls commented 7 years ago

Coverage Status

Changes Unknown when pulling c004904b196c54668c7066adb1b6f4d4c282ecaf on idanen:feature/firebase-3-link-user into on firebase:master.

idanen commented 7 years ago

Is the CLA check going to re-run at some time?

Or should I replace author email (folowing these steps)?

googlebot commented 7 years ago

CLAs look good, thanks!

jamesdaniels commented 4 years ago

Thanks for the contribution however we're only considering security fixes at this point.