#Editing profile works fine apart from the password.

13 messages · Page 1 of 1 (latest)

static flax
#

Trying to edit the profile works fine, but if i want to change the password, it says the update was successful, but if i try to log in it says the credentials are not working. This happens if i try to edit any other aspect of the profile too.

public function edit()
    {
        $this->validate();

        $attributes = $this->all();

        $user = User::findOrFail($this->user->id);

        if($this->pfp_directory) {
            $attributes['pfp_directory'] = $this->pfp_directory->store('profiles', 'public');
        }
        else
        {
            unset($attributes['pfp_directory']);
        }

        if($this->password) {
            $attributes['password'] = $this->password;
            $this->user->password = $attributes['password'];
        }
        else
        {
            unset($attributes['password']);
        }

        $this->user->name = $attributes['name'] ?? $this->user->name;
        $this->user->username = $attributes['username'] ?? $this->user->username;
        $this->user->pfp_directory = $attributes['pfp_directory'] ?? $this->user->pfp_directory;
        $this->user->bio = $attributes['bio'] ?? $this->user->bio;
        $this->user->email = $attributes['email'] ?? $this->user->email;

        $this->user->save();

        return redirect('/profile/' . $user->username)->with('success', 'Successfully updated!');
    }
eager cave
#

because you need to run the password through Hash::make

static flax
eager cave
#

was that there by default?

#

also is password fillable

static flax
static flax
eager cave
#

It's difficult to read your code tbh, see what laravel breeze/Jetstream does

frozen rover
#

change your password and look at the DB

#

is it hashed orn ot

#

if its not

        $this->user->password = Hash:make($attributes['password']);
#

but you are violating a lot of coding standards there tbh i'd look at some guides online and try make it cleaner

static flax
#

i fixed it, im using livewire and i missed some parameters