Skip to content

Commit

Permalink
feat: Save notification when changed password
Browse files Browse the repository at this point in the history
  • Loading branch information
StaNov committed Jan 23, 2025
1 parent 774569d commit e8eceed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ enum class NotificationType {
TASK_COMPLETED,
MFA_ENABLED,
MFA_DISABLED,
PASSWORD_CHANGED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,13 @@ class UserAccountService(
userAccount.tokensValidNotBefore = DateUtils.truncate(Date(), Calendar.SECOND)
userAccount.password = passwordEncoder.encode(dto.password)
userAccount.passwordChanged = true
return userAccountRepository.save(userAccount)
val savedUser = userAccountRepository.save(userAccount)
notificationService.save(Notification().apply {
this.user = userAccount
this.type = NotificationType.PASSWORD_CHANGED
this.originatingUser = userAccount
})
return savedUser
}

private fun updateUserEmail(
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/component/layout/TopBar/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ function getLocalizedMessage(
return <T keyName="notifications-mfa-enabled" />;
case 'MFA_DISABLED':
return <T keyName="notifications-mfa-disabled" />;
case 'PASSWORD_CHANGED':
return <T keyName="notifications-password-changed" />;
}
}

Expand Down
7 changes: 6 additions & 1 deletion webapp/src/service/apiSchema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2927,7 +2927,12 @@ export interface components {
linkedTask?: components["schemas"]["TaskModel"];
originatingUser?: components["schemas"]["SimpleUserAccountModel"];
project?: components["schemas"]["SimpleProjectModel"];
type: "TASK_ASSIGNED" | "TASK_COMPLETED" | "MFA_ENABLED" | "MFA_DISABLED";
type:
| "TASK_ASSIGNED"
| "TASK_COMPLETED"
| "MFA_ENABLED"
| "MFA_DISABLED"
| "PASSWORD_CHANGED";
};
NotificationsMarkSeenRequest: {
/**
Expand Down

0 comments on commit e8eceed

Please sign in to comment.