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