Added Passkey login, fixed password reset as a result of updating laravel
This commit is contained in:
@@ -7,16 +7,26 @@ use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Display the form to request a password reset link.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
return view('adminlte::auth.passwords.email');
|
||||
}
|
||||
}
|
||||
|
@@ -4,26 +4,46 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Display the password reset view for the given token.
|
||||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showResetForm(Request $request)
|
||||
{
|
||||
$token = $request->route()->parameter('token');
|
||||
|
||||
return view('adminlte::auth.passwords.reset')
|
||||
->with([
|
||||
'token' => $token,
|
||||
'email' => $request->email
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,38 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
use App\Http\Requests\UserEdit;
|
||||
use App\Models\{Supplier,User};
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update user settings
|
||||
*
|
||||
* @param UserEdit $request
|
||||
* @param User $o
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function edit(UserEdit $request,User $o): RedirectResponse
|
||||
{
|
||||
foreach (Arr::except($request->validated(),['password']) as $field => $value)
|
||||
$o->{$field} = $value;
|
||||
|
||||
if ($x=$request->validated('password'))
|
||||
$o->password = Hash::make($x);
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success',($o->isDirty() && $o->save()) ? 'User Updated' : 'No Changes');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a supplier to a user's profile
|
||||
*
|
||||
|
39
app/Http/Requests/UserEdit.php
Normal file
39
app/Http/Requests/UserEdit.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class UserEdit extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::id() === $this->route('o')->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email'=>'required|email|min:5',
|
||||
'password'=>['nullable','confirmed',Password::min(8)],
|
||||
'firstname'=>'required|min:2',
|
||||
'lastname'=>'required|min:2',
|
||||
'address1'=>'required|min:8',
|
||||
'address2'=>'nullable|min:8',
|
||||
'city'=>'required|min:4',
|
||||
'state'=>'required|min:3|max:3',
|
||||
'postcode'=>'required|min:4|max:4',
|
||||
'country_id'=>'required|exists:countries,id'
|
||||
];
|
||||
}
|
||||
}
|
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Leenooks\Traits\ScopeActive;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
use ScopeActive;
|
||||
|
||||
public $timestamps = FALSE;
|
||||
|
||||
/* RELATIONS */
|
||||
|
@@ -29,6 +29,7 @@ class User extends Authenticatable implements IDs
|
||||
|
||||
protected $casts = [
|
||||
'last_access' => 'datetime:Y-m-d H:i:s',
|
||||
'passkey' => 'json',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
@@ -9,25 +10,27 @@ use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ResetPassword extends ResetPasswordNotification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
||||
}
|
||||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return MailMessage
|
||||
*/
|
||||
public function toMail($notifiable): MailMessage
|
||||
{
|
||||
$site = Site::findOrFail($notifiable->site_id);
|
||||
|
||||
return (new MailMessage)
|
||||
->markdown('email.user.passwordreset',[
|
||||
'site'=>$notifiable->site,
|
||||
'user'=>$notifiable,
|
||||
'reset_link'=>route('password.reset',$this->token,true),
|
||||
]);
|
||||
}
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
||||
}
|
||||
|
||||
return (new MailMessage)
|
||||
->markdown('email.user.passwordreset',[
|
||||
'site'=>$site,
|
||||
'user'=>$notifiable,
|
||||
'reset_link'=>route('password.reset',$this->token,true),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user