#php artisan make:filament-user bug

15 messages · Page 1 of 1 (latest)

tame olive
#

I want to create an account via the terminal by running the php artisan command make:filament-user. but when I try to log in, I can't. but after I changed the password via the database using bcrypt manually

gentle fogBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

tame monolith
#

Ok I think you might be double hashing it, try to remove the hashed cast

#

Then see how it saves

tame olive
#

fixed

tame olive
#

i deleted the

public function setPasswordAttribute($password)
    {
        $this->attributes['password'] = bcrypt($password);
    }

in User.php models

tame monolith
#

So that's a cast

#

Was it already there?

#

you should be checking if the password is already hashed when casting like that

tame olive
#
<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Support\Facades\Storage;


use Spatie\Permission\Traits\HasRoles;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;

use TomatoPHP\FilamentDiscord\Traits\InteractsWithDiscord;

class User extends Authenticatable implements HasAvatar, FilamentUser
{
    use HasApiTokens;
    use HasRoles;
    use HasPanelShield;
    use HasFactory;
    use Notifiable;
    use InteractsWithDiscord;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */

    protected $guarded = [
        'id',
    ];
    // protected $fillable = [
    //     'name',
    //     'no_hp',
    //     'alamat',
    //     'email',
    //     'password',
    //     'role',
    //     'cabangs_id',
    //     'bisnis_id',
    // ];
    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
    ];

    // public function setPasswordAttribute($password)
    // {
    //     $this->attributes['password'] = bcrypt($password);
    // }


    // public function addres() : Morphone 
    // {
    //     return $this->morphone(related:addres::class,name:'addresable');
    // }

    public function getFilamentAvatarUrl(): ?string
    {
        return $this->avatar_url ? Storage::url("$this->avatar_url") : null;
    }

    public function bisnis()
    {
        return $this->belongsTo(Bisnis::class);
    }
    public function cabang()
    {
        return $this->belongsTo(Cabang::class, 'cabangs_id');
    }

    public function canAccessPanel(Panel $panel): bool
    {
        return $this->email && $this->password;
    }
    
}
tame monolith
#

That'll be why then it was double hashing it.

tame olive
#

idk why i have this code

    // public function setPasswordAttribute($password)
    // {
    //     $this->attributes['password'] = bcrypt($password);
    // }
tame monolith
#

Me neither.