1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Fixes for password confirmation validation form

This commit is contained in:
David Bomba 2022-08-11 07:50:45 +10:00
parent 4573bd916b
commit a5bef4240a

View File

@ -17,6 +17,7 @@ use App\Utils\Traits\MakesHash;
use App\Utils\Traits\UserSessionAttributes;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
/**
* Class VerifiesUserEmail.
@ -33,14 +34,12 @@ trait VerifiesUserEmail
{
$user = User::where('confirmation_code', request()->confirmation_code)->first();
// if ($user = User::whereRaw("BINARY `confirmation_code`= ?", request()->input('confirmation_code'))->first()) {
if (! $user) {
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
}
$user->email_verified_at = now();
$user->confirmation_code = null;
// $user->confirmation_code = null; //this prevented the form from showing validation errors.
$user->save();
if (isset($user->oauth_user_id)) {
@ -64,12 +63,18 @@ trait VerifiesUserEmail
{
$user = User::where('id', $this->decodePrimaryKey(request()->user_id))->firstOrFail();
request()->validate([
$validator = Validator::make(request()->all(), [
//'password' => ['required', 'min:6'],
'password' => 'min:6|required_with:password_confirmation|same:password_confirmation',
'password_confirmation' => 'min:6'
]);
if ($validator->fails()) {
return back()
->withErrors($validator)
->withInput();
}
$user->password = Hash::make(request()->password);
$user->email_verified_at = now();