如何使用 Firebase 电子邮件地址验证

How to use Firebase email address verification

在 Firebase Web SDK3 中似乎有一个确认电子邮件地址的选项,请参阅 here(将您自己的项目 ID 放在 link 中),但我找不到有关如何确认的文档使用它。

有人做过吗?

隐藏得很好,但给你:https://firebase.google.com/docs/reference/js/firebase.User#sendEmailVerification

然后您只需要在身份验证流程中检查 emailVerified

简而言之,下面是您在 AngularJS:

中的基本处理方法
// thecontroller.js
$scope.sendVerifyEmail = function() {
    console.log('Email sent, whaaaaam!');
    currentAuth.sendEmailVerification();
  }

// where currentAuth came from something like this:
// routerconfig

....
templateUrl: 'bla.html',
resolve: {
    currentAuth:['Auth', function(Auth) {
      return Auth.$requireSignIn() // this throws an AUTH_REQUIRED broadcast
    }]
  }
...

// intercept the broadcast like so if you want:

....

$rootScope.$on("$stateChangeError", function(event, toState, toParams, fromState, fromParams, error) {
      if (error === "AUTH_REQUIRED") {
        $state.go('login', { toWhere: toState });
       }
    });
....

// So user receives the email. How do you process the `oobCode` that returns?
// You may do something like this:

// catch the url with its mode and oobCode
.state('emailVerify', {
  url: '/verify-email?mode&oobCode',
  templateUrl: 'auth/verify-email.html',
  controller: 'emailVerifyController',
  resolve: {
    currentAuth:['Auth', function(Auth) {
      return Auth.$requireSignIn()
    }]
  }
})

// Then digest like so where each term is what they sound like:

.controller('emailVerifyController', ['$scope', '$stateParams', 'currentAuth', 'DatabaseRef',
  function($scope, $stateParams, currentAuth, DatabaseRef) {
    console.log(currentAuth);
    $scope.doVerify = function() {
      firebase.auth()
        .applyActionCode($stateParams.oobCode)
        .then(function(data) {
          // change emailVerified for logged in User
          console.log('Verification happened');
        })
        .catch(function(error) {
          $scope.error = error.message;
          console.log(error.message, error.reason)
        })
    };
  }
])

文章中有更多解释Email Verification with Firebase 3.0 SDK