2016-08-24 13 views
0

アクティブでないユーザーを処理し、アクティブでない限りそれらを保持します。現在のところ、私は彼らにアクティブではなく、ログインさせるように警告しています。しかし、ログインエラーを投げて、アクティブでない限り、それらを保持したいだけです。 「アクティブ」とは、電子メールトークンを有効にしていないことを意味します。ログイン時に非アクティブなユーザーを処理するためのangularjs

'use strict'; 

angular.module('myapp').controller('LoginCtrl', function ($scope, alert, auth, $state, $auth, $timeout) { 

    $scope.submit = function() { 
    $auth.login({ 
     email: $scope.email, 
     password: $scope.password 
    }) 
     .then(function(res) { 
     var message = 'Thanks for coming back ' + res.data.user.email + '!'; 
     if (!res.data.user.active) 
      message = 'Just a reminder, please activate your account soon :)'; 
     alert('success', 'Welcome', message); 
     return null; 
     }) 
     .then(function() { 
     $timeout(function() { 
      $state.go('main'); 
     }); 
     }) 
     .catch(handleError); 
    } 

    function handleError(err) { 
    alert('warning', 'oops there is a problem!', err.message); 
    } 


}); 

答えて

0

あなたはいつも$auth.logout()ですぐにログアウトできます。

+0

その後、この行にコードを挿入する必要がありますか? – qpro

+0

'if(!res.data.user.active)'ブロックの内部にあります。また、ブロック内にアラートメッセージを表示して、アクティブ化する必要があることを伝えることもできます。 – peaches

関連する問題