I'm trying to send a reset password link to email using mailgun and Laravel default Password Reset.
Here's my UserAccount model :
class UserAccount extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
protected $table = "UserAccounts";
protected $fillable = ['AccountName', 'EmployeeID', 'Username', 'Password', 'Email', 'UserType'];
protected $hidden = ['Password', 'remember_token'];
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 setPasswordAttribute($password){
$this->attributes['Password'] = bcrypt($password);
}
public function getEmailForPasswordReset(){
return $this->Email;
}
}
.
.
Here's my PasswordController :
class PasswordController extends Controller {
use ResetsPasswords;
protected $redirectTo = '/employee';
public function __construct(Guard $auth, PasswordBroker $passwords){
$this->auth = $auth;
$this->passwords = $passwords;
$this->middleware('guest');
}
public function getEmail(){
return view('auth.password');
}
public function postEmail(Request $request){
//validate email
$search = UserAccount::getUserAccountByAccountNameAndUsername($request->accountName, $request->username);
if(count($search)>0){
$userAccount = $search[0];
if($userAccount->employee->Email == $request->email){
$response = $this->passwords->sendResetLink($request->only('email'), function($m)
{
$m->subject($this->getEmailSubject());
});
switch ($response)
{
case PasswordBroker::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case PasswordBroker::INVALID_USER:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}else{
flash()->error('Incorrect email.');
return redirect()->back()->withInput();
}
}else{
flash()->error('User not found.');
return redirect()->back()->withInput();
}
}
}
I'm using mailgun and already set the domain
and secret
in config/services.php.
This is my config/mail.php :
return [
'driver' => 'mailgun',
'host' => 'smtp.mailgun.org',
'port' => 587,
'from' => ['address' => 'hello@mail.com', 'name' => 'Hello'],
'encryption' => 'tls',
'username' => null,
'password' => null,
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
I already add "guzzlehttp/guzzle": "^4.0"
in composer.json and already done composer update
.
However, I always get BAD REQUEST error :
ClientException in RequestException.php line 71:
Client error response [url] http://ift.tt/1UHRlPM [status code] 400 [reason phrase] BAD REQUEST
And I already done whatever is in this SO post : Sending Email with mailgun in laravel error , but still have no luck at all.
Please help.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1X2imvW
via IFTTT
Aucun commentaire:
Enregistrer un commentaire