fix: 로그인/세션 갱신만 있는 member 수정은 활동 로그 제외
페이지 접속·로그인 시 세션토큰/접속시각 갱신이 '로그인'으로 잔뜩 기록되던 노이즈 제거. Auditable에 auditSkipUpdateOnlyFields 추가, MemberModel에서 세션/로그인 필드 지정. (로그인 자체는 '로그인 이력'에서 별도 확인) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,9 @@ class MemberModel extends Model
|
||||
{
|
||||
use \App\Models\Traits\Auditable;
|
||||
|
||||
/** 로그인/세션 갱신만 있는 update는 활동 로그에 남기지 않음(로그인 이력은 별도 기록) */
|
||||
protected array $auditSkipUpdateOnlyFields = ['mb_latestdate', 'mb_login_fail_count', 'mb_locked_until', 'mb_session_token'];
|
||||
|
||||
protected $table = 'member';
|
||||
protected $primaryKey = 'mb_idx';
|
||||
protected $returnType = 'object';
|
||||
|
||||
@@ -38,6 +38,13 @@ trait Auditable
|
||||
/** 마스킹 대상 필드명 */
|
||||
protected array $auditMaskFields = ['mb_passwd', 'mb_totp_secret', 'mb_session_token', 'mb_email', 'mb_phone'];
|
||||
|
||||
/**
|
||||
* 이 필드들'만' 변경된 update는 활동 로그를 남기지 않는다.
|
||||
* (예: 로그인/세션 갱신 같은 시스템 내부 변경 — 노이즈 제거)
|
||||
* 모델에서 재정의해 사용.
|
||||
*/
|
||||
protected array $auditSkipUpdateOnlyFields = [];
|
||||
|
||||
private function auditMask(?array $row): ?array
|
||||
{
|
||||
if ($row === null) {
|
||||
@@ -98,6 +105,16 @@ trait Auditable
|
||||
$ids = $eventData['id'] ?? null;
|
||||
$changes = is_array($eventData['data'] ?? null) ? $eventData['data'] : [];
|
||||
|
||||
// 지정 필드만 변경된 경우(로그인/세션 갱신 등) → 기록 생략
|
||||
if ($this->auditSkipUpdateOnlyFields !== [] && $changes !== []) {
|
||||
$changedKeys = array_values(array_diff(array_keys($changes), [$this->primaryKey]));
|
||||
if ($changedKeys !== [] && array_diff($changedKeys, $this->auditSkipUpdateOnlyFields) === []) {
|
||||
$this->auditBeforeRows = [];
|
||||
|
||||
return $eventData;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ids !== null) {
|
||||
foreach ((array) $ids as $one) {
|
||||
$before = $this->auditBeforeRows[(string) $one] ?? null;
|
||||
|
||||
Reference in New Issue
Block a user