Skip to content

Commit c93f2fc

Browse files
Merge pull request #174 from lvdigitalaaank/master
Translators unable to change their passwords
2 parents c0378d3 + cb13ade commit c93f2fc

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/Http/Controllers/ProfileController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function update(Request $request): RedirectResponse
3535
public function updatePassword(Request $request): RedirectResponse
3636
{
3737
$validated = $request->validate([
38-
'current_password' => ['required', 'current_password'],
38+
'current_password' => ['required', 'current_password:translations'],
3939
'password' => ['required', Password::defaults(), 'confirmed'],
4040
]);
4141

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Outhebox\TranslationsUI\Tests\Http\Controllers;
4+
5+
use Illuminate\Support\Facades\Hash;
6+
use Outhebox\TranslationsUI\Tests\TestCase;
7+
use Outhebox\TranslationsUI\Models\Contributor;
8+
use Outhebox\TranslationsUI\Enums\RoleEnum;
9+
10+
class PasswordUpdateTest extends TestCase
11+
{
12+
/** @test */
13+
public function translator_can_update_password_when_default_guard_is_web()
14+
{
15+
// Set default guard to something else
16+
config(['auth.defaults.guard' => 'web']);
17+
18+
$translator = Contributor::factory()->create([
19+
'role' => RoleEnum::translator,
20+
'password' => Hash::make('old-password'),
21+
]);
22+
23+
$response = $this->actingAs($translator, 'translations')
24+
->from(route('ltu.profile.edit'))
25+
->put(route('ltu.profile.password.update'), [
26+
'current_password' => 'old-password',
27+
'password' => 'new-password123',
28+
'password_confirmation' => 'new-password123',
29+
]);
30+
31+
$response->assertSessionHasNoErrors();
32+
$response->assertRedirect(route('ltu.profile.edit'));
33+
34+
$this->assertTrue(Hash::check('new-password123', $translator->refresh()->password));
35+
}
36+
}

0 commit comments

Comments
 (0)