Skip to content
Snippets Groups Projects
Commit 8363d524 authored by Maxime FRIESS's avatar Maxime FRIESS :blue_heart:
Browse files

Merge branch 'feature/fix-profile-update' into 'develop'

Fixed password update

See merge request !5
parents 07035f84 7c9efb3c
Branches
Tags
1 merge request!5Fixed password update
Pipeline #100564 passed with stages
in 43 seconds
......@@ -5,6 +5,7 @@
use App\Http\Requests\UpdateProfileRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
class ProfileController extends Controller
{
......@@ -79,7 +80,11 @@ public function show()
*/
public function update(UpdateProfileRequest $request)
{
Auth::user()->update($request->validated());
$data = $request->validated();
if (array_key_exists('password', $data))
$data['password'] = Hash::make($data['password']);
Auth::user()->update($data);
return response()->noContent();
}
......
......@@ -158,4 +158,27 @@ public function test_update_good() {
]);
$response->assertStatus(204);
}
public function test_change_password() {
$user = User::create([
'username' => 'test',
'email' => 'test@localhost',
'password' => Hash::make('test'),
]);
$token = Auth::login($user);
$response = $this->withHeaders([
"Authorization" => "Bearer " . $token
])->put('/api/auth/profile', [
'password' => 'testtest',
]);
$response->assertStatus(204);
$response = $this->postJson("/api/auth/login", [
"username" => "test",
"password" => "testtest",
]);
$response->assertStatus(200);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment