@artekha

Как поправить auth в firebase?

Делаю авторизацию с помощью angular-fire и firebase. Если зарегаться и удалить аккаунт сразу - все нормально, но если подождать какое то время или перезапустить сервак, то при удалении будет такая ошибка: This operation is sensitive and requires recent authentication. Log in again before retrying this request.
Код ошибки: auth/requires-recent-login
Как решить проблему с удалением аккаунта, что бы не нужно было авторизироваться по новой?
Код контроллера для авторизации:
app.controller('authCtrl', ['$scope', 'Auth', '$location', function($scope, Auth, $location) {

  $scope.authError = null;
  $scope.userEmail = null;
  $scope.auth = Auth;

  // any time auth state changes, add the user data to scope
  $scope.auth.$onAuthStateChanged(function(firebaseUser) {
    $scope.firebaseUser = firebaseUser ? firebaseUser.email : null;
  });

  // Create User
  $scope.createUser = function() {
    $scope.authError = null;
    Auth.$createUserWithEmailAndPassword($scope.email, $scope.password)
      .then(
        function(firebaseUser) {
          $location.path('/contacts');
          $scope.userEmail = firebaseUser.email;
        },
        function(error) {
          $scope.authError = error.message;
        }
      );
  };

  // Delete User
  $scope.deleteUser = function() {
    $scope.authError = null;
    Auth.$deleteUser().then(
      function() {
        $location.path('/auth');
        $scope.userEmail = null;
      },
      function(error) {
        $scope.authError = error.message + ' ' + error.code;
      }
    )

  };

  // LogIn
  $scope.logIn = function() {
    Auth.$signInWithEmailAndPassword($scope.email, $scope.password)
      .then(
        function(firebaseUser) {
          $location.path('/contacts');
          $scope.userEmail = firebaseUser.email;
        },
        function(error) {
          $scope.authError = error.message;
        }
      );
  };
}]);
  • Вопрос задан
  • 404 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы