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!');
}