mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 06:14:35 -04:00
Set password for new users
This commit is contained in:
parent
8f91969c49
commit
0225526756
@ -13,6 +13,7 @@
|
|||||||
namespace App\Http\Controllers\Traits;
|
namespace App\Http\Controllers\Traits;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\UserSessionAttributes;
|
use App\Utils\Traits\UserSessionAttributes;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
@ -23,6 +24,7 @@ use Illuminate\Support\Facades\Hash;
|
|||||||
trait VerifiesUserEmail
|
trait VerifiesUserEmail
|
||||||
{
|
{
|
||||||
use UserSessionAttributes;
|
use UserSessionAttributes;
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return RedirectResponse
|
* @return RedirectResponse
|
||||||
@ -37,14 +39,14 @@ trait VerifiesUserEmail
|
|||||||
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
|
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($user->password) || empty($user->password)) {
|
|
||||||
return $this->render('auth.confirmation_with_password', ['root' => 'themes']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->email_verified_at = now();
|
$user->email_verified_at = now();
|
||||||
$user->confirmation_code = null;
|
$user->confirmation_code = null;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
|
if (is_null($user->password) || empty($user->password) || Hash::check('', $user->password)) {
|
||||||
|
return $this->render('auth.confirmation_with_password', ['root' => 'themes', 'user_id' => $user->hashed_id]);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('auth.confirmed', [
|
return $this->render('auth.confirmed', [
|
||||||
'root' => 'themes',
|
'root' => 'themes',
|
||||||
'message' => ctrans('texts.security_confirmation'),
|
'message' => ctrans('texts.security_confirmation'),
|
||||||
@ -53,16 +55,13 @@ trait VerifiesUserEmail
|
|||||||
|
|
||||||
public function confirmWithPassword()
|
public function confirmWithPassword()
|
||||||
{
|
{
|
||||||
$user = User::where('confirmation_code', request()->confirmation_code)->first();
|
$user = User::where('id', $this->decodePrimaryKey(request()->user_id))->firstOrFail();
|
||||||
|
|
||||||
if (! $user) {
|
|
||||||
return $this->render('auth.confirmed', ['root' => 'themes', 'message' => ctrans('texts.wrong_confirmation')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
request()->validate([
|
request()->validate([
|
||||||
'password' => ['required', 'min:6', 'confirmed'],
|
'password' => ['required', 'min:6'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$user->password = Hash::make(request()->password);
|
$user->password = Hash::make(request()->password);
|
||||||
|
|
||||||
$user->email_verified_at = now();
|
$user->email_verified_at = now();
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
<form action="{{ url()->current() }}" method="post" class="mt-6">
|
<form action="{{ url()->current() }}" method="post" class="mt-6">
|
||||||
@csrf
|
@csrf
|
||||||
|
<input type="hidden" name="user_id" value="{{ $user_id }}">
|
||||||
<div class="flex flex-col mt-4">
|
<div class="flex flex-col mt-4">
|
||||||
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
|
<label for="password" class="input-label">{{ ctrans('texts.password') }}</label>
|
||||||
<input type="password" name="password" id="password"
|
<input type="password" name="password" id="password"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user