1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Fix client reset password

This commit is contained in:
Hillel Coren 2017-11-14 22:34:56 +02:00
parent 7dd7fd16ba
commit 38d322389b
12 changed files with 66 additions and 3 deletions

View File

@ -6,6 +6,7 @@ use Password;
use Config;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
class ResetPasswordController extends Controller
{
@ -48,13 +49,13 @@ class ResetPasswordController extends Controller
protected function guard()
{
return auth()->guard('clients');
return auth()->guard('client');
}
public function showResetForm(Request $request, $token = null)
{
return view('clientauth.passwords.reset')->with(
['token' => $token, 'email' => $request->email]
['token' => $token]
);
}

View File

@ -104,7 +104,7 @@ Route::get('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\LoginControl
Route::get('/client/logout', ['as' => 'logout', 'uses' => 'ClientAuth\LoginController@getLogout']);
Route::get('/client/session_expired', ['as' => 'logout', 'uses' => 'ClientAuth\LoginController@getSessionExpired']);
Route::get('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\ForgotPasswordController@showLinkRequestForm']);
Route::get('/client/password/reset/{token}', ['as' => 'forgot', 'uses' => 'Auth\ResetPasswordController@showResetForm']);
Route::get('/client/password/reset/{token}', ['as' => 'forgot', 'uses' => 'ClientAuth\ResetPasswordController@showResetForm']);
Route::group(['middleware' => ['lookup:contact']], function () {
Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\LoginController@login']);

View File

@ -183,6 +183,12 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa
return "{$url}/client/dashboard/{$this->contact_key}";
}
public function sendPasswordResetNotification($token)
{
//$this->notify(new ResetPasswordNotification($token));
app('App\Ninja\Mailers\ContactMailer')->sendPasswordReset($this, $token);
}
}
Contact::creating(function ($contact)

View File

@ -421,6 +421,12 @@ class User extends Authenticatable
{
return $this->account->company->accounts->sortBy('id')->first();
}
public function sendPasswordResetNotification($token)
{
//$this->notify(new ResetPasswordNotification($token));
app('App\Ninja\Mailers\UserMailer')->sendPasswordReset($this, $token);
}
}
User::created(function ($user)

View File

@ -327,4 +327,19 @@ class ContactMailer extends Mailer
$this->sendTo($email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
public function sendPasswordReset($contact, $token)
{
if (! $contact->email) {
return;
}
$subject = trans('texts.your_password_reset_link');
$view = 'client_password';
$data = [
'token' => $token,
];
$this->sendTo($contact->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
}

View File

@ -154,4 +154,19 @@ class UserMailer extends Mailer
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
public function sendPasswordReset($user, $token)
{
if (! $user->email) {
return;
}
$subject = trans('texts.your_password_reset_link');
$view = 'password';
$data = [
'token' => $token,
];
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
}

View File

@ -2521,6 +2521,7 @@ $LANG = array(
'self_host_login' => 'Self-Host Login',
'set_self_hoat_url' => 'Self-Host URL',
'local_storage_required' => 'Error: local storage is not available.',
'your_password_reset_link' => 'Your Password Reset Link',
);

View File

@ -35,6 +35,7 @@
<input type="hidden" name="token" value="{{{ $token }}}">
<div>
{!! Former::text('email')->placeholder(trans('texts.email'))->raw() !!}
{!! Former::password('password')->placeholder(trans('texts.password'))->raw() !!}
{!! Former::password('password_confirmation')->placeholder(trans('texts.confirm_password'))->raw() !!}
</div>

View File

@ -0,0 +1,10 @@
{{ trans('texts.reset_password') }}
{!! URL::to(SITE_URL . "/client/password/reset/{$token}") !!}
@if (Utils::isNinja() || ! Utils::isWhiteLabel())
{{ trans('texts.email_signature') }}<br/>
{{ trans('texts.email_from') }}
@endif
{{ trans('texts.reset_password_footer', ['email' => env('CONTACT_EMAIL', CONTACT_EMAIL)]) }}

View File

@ -0,0 +1,8 @@
{{ trans('texts.reset_password') }}
{!! URL::to(SITE_URL . "/password/reset/{$token}") !!}
{{ trans('texts.email_signature') }}
{{ trans('texts.email_from') }}
{{ trans('texts.reset_password_footer', ['email' => env('CONTACT_EMAIL', CONTACT_EMAIL)]) }}