Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F125361353
D5896.1779443026.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D5896.1779443026.diff
View Options
diff --git a/bin/phpcs b/bin/phpcs
--- a/bin/phpcs
+++ b/bin/phpcs
@@ -11,6 +11,6 @@
cmd=$1
fi
-php vendor/bin/php-cs-fixer $cmd --using-cache=no --diff --verbose
+php -dmemory_limit=1000M vendor/bin/php-cs-fixer $cmd --using-cache=no --diff --verbose
popd
diff --git a/src/app/EventLog.php b/src/app/EventLog.php
--- a/src/app/EventLog.php
+++ b/src/app/EventLog.php
@@ -26,6 +26,7 @@
public const TYPE_UNSUSPENDED = 2;
public const TYPE_COMMENT = 3;
public const TYPE_MAILSENT = 4;
+ public const TYPE_PASS_CHANGE = 5;
/** @var list<string> The attributes that are mass assignable */
protected $fillable = [
@@ -104,6 +105,8 @@
return \trans('app.event-comment');
case self::TYPE_MAILSENT:
return \trans('app.event-mailsent');
+ case self::TYPE_PASS_CHANGE:
+ return \trans('app.event-passchange');
default:
return null;
}
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -243,11 +243,7 @@
// Password change
$oldPassword = $user->getOriginal('password');
if ($oldPassword && $user->password != $oldPassword) {
- // Reset the password expiration settings
- $user->removeSettingsQuietly(['password_expired', 'password_expiration_warning']);
-
- // Save the old password in the password history
- self::saveOldPassword($user, $oldPassword);
+ self::passwordUpdated($user, $oldPassword);
}
}
@@ -310,13 +306,18 @@
* @param User $user The user
* @param string $password The old password
*/
- private static function saveOldPassword(User $user, string $password): void
+ private static function passwordUpdated(User $user, string $password): void
{
+ // Reset the password expiration settings
+ $user->removeSettingsQuietly(['password_expired', 'password_expiration_warning']);
+
// Remember the timestamp of the last password change
// Note: We could get this from user_passwords table, but only if the policy
// enables storing of old passwords there.
$user->setSetting('password_update', now()->format('Y-m-d H:i:s'));
Password::saveHash($user, $password);
+
+ EventLog::createFor($user, EventLog::TYPE_PASS_CHANGE);
}
}
diff --git a/src/resources/lang/en/app.php b/src/resources/lang/en/app.php
--- a/src/resources/lang/en/app.php
+++ b/src/resources/lang/en/app.php
@@ -34,6 +34,7 @@
'event-unsuspended' => 'Unsuspended',
'event-comment' => 'Commented',
'event-mailsent' => 'Mail Sent',
+ 'event-passchange' => 'Password Change',
'mandate-delete-success' => 'The auto-payment has been removed.',
'mandate-update-success' => 'The auto-payment has been updated.',
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -545,6 +545,7 @@
'/^' . now()->format('Y-m-d') . ' [0-9]{2}:[0-9]{2}:[0-9]{2}$/',
$user->getSetting('password_update')
);
+ $this->assertCount(1, EventLog::where('object_id', $user->id)->where('type', EventLog::TYPE_PASS_CHANGE)->get());
Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, May 22, 9:43 AM (15 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18929687
Default Alt Text
D5896.1779443026.diff (3 KB)
Attached To
Mode
D5896: Add "password change" event to the history
Attached
Detach File
Event Timeline