2016-09-26 5 views
-1
/* 
|-------------------------------------------------------------------------- 
| Password Reset Settings 
|-------------------------------------------------------------------------- 
| 
| Here you may set the options for resetting passwords including the view 
| that is your password reset e-mail. You can also set the name of the 
| table that maintains all of the reset tokens for your application. 
| 
| The expire time is the number of minutes that the reset token should be 
| considered valid. This security feature keeps tokens short-lived so 
| they have less time to be guessed. You may change this as needed. 
| 
*/ 

'password' => [ 
    'email' => 'emails.password', 
    'table' => 'password_resets', 
    'expire' => 60, 
], 

이 password_resets 테이블의 토큰과 마찬가지로 토큰을 생성하려고합니다. 그러나 나는 이것이 어떻게 작동하는지 이해하지 못한다.laravel 5.1의 password_reset 테이블에있는 토큰 필드처럼 얼마 후에 만료 될 토큰을 생성 할 수 있습니까?

답변

1

password_resets 테이블에는 email,token,created_at의 세 필드가 있습니다. 토큰을 생성하면 날짜 시간은 created_at 필드에 저장됩니다. 이 토큰을 사용할 때 토큰이 만료 시간보다 오래되었는지 확인하십시오. 그럴 경우 토큰이 유효하지 않습니다. 그렇지 않으면 유효합니다. 프로세스를 수행하고 두 경우 모두 해당 토큰을 파괴하십시오.

+0

그런 다음 구현해야합니다. laravel이 그것을 도와 줄 수 있는지 궁금한가요? – rat

+0

@rat 내가 아는 한, 도우미가 없다. – Sovon

1

DatabaseTokenRepository에 토큰을 저장하려는 경우 Illuminate\Auth\Passwords\TokenRepositoryInterface 인터페이스를 구현하는 Illuminate\Auth\Passwords\DatabaseTokenRepository을 사용할 수 있습니다. 'auth.password.tokens'으로도 등록됩니다.

create 메소드에는 하나의 필수 매개 변수가 있습니다.

/** 
* Create a new token record. 
* 
* @param \Illuminate\Contracts\Auth\CanResetPassword $user 
* @return string 
*/ 
public function create(CanResetPasswordContract $user); 

이 클래스는 Illuminate\Contracts\Auth\PasswordBroker 인터페이스를 구현하는 Illuminate\Auth\Passwords\PasswordBroker 클래스에서 사용되는 : 여기에 서명입니다. 여기에서 저장소의 사용 예를 볼 수 있습니다.

참고 : PasswordBroker를 사용하려면 app()->make('auth.password')을 사용해보십시오.