Jetstream 修改认证逻辑后无法删除账号。 (Laravel 9、Jetstream、惯性、VueJs3)

Jetstream unable to delete account after modifying the authentication logic. (Laravel 9,Jetstream, Inertia, VueJs3)

最近决定在登录页面添加一个字段(用户名),它是唯一的。

登录时,您可以使用用户名或电子邮件。

修改后,“登录”、“注册”、“修改密码”、“重置密码”、“邮箱验证”功能正常

“双因素身份验证”、“浏览器会话”、“删除帐户”不起作用,只是想知道出了什么问题

当我尝试删除帐户或从所有浏览器会话中注销时,弹出

for more detailed error https://flareapp.io/share/17DK4R9P#F73

config/fortify

'username' => 'auth',

'email' => 'email',

Models/User.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use JoelButcher\Socialstream\HasConnectedAccounts;
use JoelButcher\Socialstream\SetsProfilePhotoFromUrl;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Jetstream\HasTeams;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Post;


class User extends Authenticatable implements MustVerifyEmail
{
    use HasApiTokens;
    use HasFactory;
    use HasProfilePhoto {
        getProfilePhotoUrlAttribute as getPhotoUrl;
    }
    use HasTeams;
    use HasConnectedAccounts;
    use Notifiable;
    use SetsProfilePhotoFromUrl;
    use TwoFactorAuthenticatable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'username'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',
        'two_factor_recovery_codes',
        'two_factor_secret',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    /**
     * The accessors to append to the model's array form.
     *
     * @var array
     */
    protected $appends = [
        'profile_photo_url',
    ];

    /**
     * Get the URL to the user's profile photo.
     *
     * @return string
     */
    public function getProfilePhotoUrlAttribute()
    {
        if (filter_var($this->profile_photo_path, FILTER_VALIDATE_URL)) {
            return $this->profile_photo_path;
        }

}

Users database

    <?php
    
    use Illuminate\Database\Migrations\Migration;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Support\Facades\Schema;
    
    class CreateUsersTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('users', function (Blueprint $table) {
                $table->id();
                $table->string('name');
                $table->string('email')->unique();
                $table->string('username')->unique();
                $table->timestamp('email_verified_at')->nullable();
                $table->string('password')->nullable();
                $table->rememberToken();
                $table->foreignId('current_team_id')->nullable();
                $table->foreignId('current_connected_account_id')->nullable();
                $table->foreignId('current_connected_post_id')->nullable();
                $table->text('profile_photo_path')->nullable();
                $table->timestamps();
            });
        }

  }
}

action/fortify/UpdatesUserProfileInformation.php

Validator::make($input, [
            'name' => ['required', 'string', 'max:255'],
            'username' => ['required', 'string', 'max:255', 'alpha_dash:users', Rule::unique('users')->ignore($user->id)],
            'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
                'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:10024'],
            ])->validateWithBag('updateProfileInformation');

action/fortify/CreatesNewUsers.php

Validator::make($input, [
            'name' => ['required', 'string', 'max:255'],
            'username' => ['required', 'string', 'max:255', 'unique:users','alpha_dash:users'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => $this->passwordRules(),
            'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '',
           
  ])->validate();

return DB::transaction(function () use ($input) {
            return tap(User::create([
                'name' => $input['name'],
                'email' => $input['email'],
                'username' => $input['username'],
                'password' => Hash::make($input['password']),
            ]), function (User $user) {
                $this->createTeam($user);
            });
        });

provides/fortifyserviceprovider.php

Fortify::authenticateUsing(function (LoginRequest $request) {
            $user = User::where('email', $request->auth)
                ->orWhere('username', $request->auth)->first();

            if (
                $user &&
                Hash::check($request->password, $user->password)
            ) {
                return $user;
            }
        });

provides/jetstreamserviceprovider.php

Fortify::authenticateUsing(function (LoginRequest $request) {
                $user = User::where('email', $request->auth)
                    ->orWhere('username', $request->auth)->first();
    
                if (
                    $user &&
                    Hash::check($request->password, $user->password)
                ) {
                    return $user;
                }
            });

我已经找到了所有这些的解决方案,

vendor/laravel/fortify/src/Actions/ConfirmPassword.php 中,有一个函数 __invoke 确认给定的密码对给定的用户有效。

默认情况下,$username = config('fortify.username'); 但我的配置 ('fortify.username') 设置为 auth 这就是为什么它不在数据库中并且 return column not found

有办法改变吗?因为修改供应商不是一个好的解决方案。