2014-10-04 115 views
1

我有一个表命名为“用户”正被哨兵使用的,但是我删除,我并不需要如激活码列,坚持规范等删除哨兵账户激活检查

这是结构我的表: Users Table

我试图登录使用我通过创建一个帐户“哨兵::的createUser()”但是“UserNotActivatedException”不断被抛出,并阻止我不能登录

这是。我的登录码:

public function postLogin() { 
    #Build login 
    if(!Input::has('email') || !Input::has('password')) { 
     return Response::json(['response' => 'Please enter an email address and a password!']); 
    } 

    try { 
     $credentials = [ 
      'email' => Input::get('email'), 
      'password' => Input::get('password') 
     ]; 

     $user = Sentry::authenticate($credentials, false); 
     return Response::json(['response' => 'You have been logged in.']); 
    } catch(Cartalyst\Sentry\Users\LoginRequiredException $e) { 
     return Response::json(['response' => 'Please enter an email address!']); 
    } catch(Cartalyst\Sentry\Users\PasswordRequiredException $e) { 
     return Response::json(['response' => 'Please enter a password!']); 
    } catch(Cartalyst\Sentry\Users\WrongPasswordException $e) { 
     return Response::json(['response' => 'That account could not be found1!']); 
    } catch(Cartalyst\Sentry\Users\UserNotFoundException $e) { 
     return Response::json(['response' => 'That account could not be found2!']); 
    } catch(Cartalyst\Sentry\Users\UserNotActivatedException $e) { 
     return Response::json(['response' => 'That account could not be found3!']); 
    } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) { 
     return Response::json(['response' => 'That account could has been suspended!']); 
    } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) { 
     return Response::json(['response' => 'That account has been banned!']); 
    } 
} 

这是正在返回的响应:

Response

有什么办法可以禁用对哨兵用户激活检查?

+0

[你有没有用'哨兵::的createUser试了一下( array('email'=>'email','password'=>'password','activated'=> true,));'](https://cartalyst.com/manual/sentry#sentry::createuser% 28%29) – Prix 2014-10-04 13:55:26

+0

我还没有尝试过,因为'激活'列在我的表内不存在。 – 2014-10-04 14:17:54

+0

[与提供的相比,你的桌子看起来相当不完整。如果您对表格进行了自定义更改,则还必须更改代码以反映您的更改,例如删除已激活帐户的验证。](https://github.com/cartalyst/sentry/blob/v2.1.4 /schema/mysql.sql) – Prix 2014-10-04 14:25:24

回答

1

我已经通过创建我自己的User类并将$ activated变量设置为true来解决了错误。 用户类别:

use Illuminate\Auth\UserInterface; 
use Illuminate\Auth\Reminders\RemindableInterface; 
use Cartalyst\Sentry\Users\Eloquent\User as SentryUserModel; 

class User extends SentryUserModel implements UserInterface, RemindableInterface { 

    public $activated = true; 

    public function getAuthIdentifier() { 
     return $this->getKey(); 
    } 

    public function getAuthPassword() { 
     return $this->password; 
    } 

    public function getRememberToken() { 
     return $this->remember_token; 
    } 

    public function setRememberToken($value) { 
     $this->remember_token = $value; 
    } 

    public function getRememberTokenName() { 
     return 'remember_token'; 
    } 

    public function getReminderEmail() { 
     return $this->email; 
    } 

} 

我还创建了两个新移民加入“persist_code”和“LAST_LOGIN”列到我的表:

use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 

class AddLastLoginToUsersTable extends Migration { 

    public function up() { 
     Schema::table('users', function(Blueprint $table) { 
      $table->string('last_login')->nullable(); 
     }); 
    } 

    public function down() { 
     Schema::table('users', function(Blueprint $table) { 
      $table->dropColumn('last_login'); 
     }); 
    } 

} 


use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 

class AddPersistCodeToUsersTable extends Migration { 

    public function up() { 
     Schema::table('users', function(Blueprint $table) { 
      $table->string('persist_code')->nullable(); 
     }); 
    } 

    public function down() { 
     Schema::table('users', function(Blueprint $table) { 
      $table->dropColumn('persist_code'); 
     }); 
    } 

}