Skip to content

fix(change_logs):add change logs entries for user update/create #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChayanDass
Copy link

add changelogs for user updates and creation

@ChayanDass ChayanDass force-pushed the change_logs_users branch 2 times, most recently from c0e40b2 to 75bc23b Compare June 23, 2025 09:01
@ChayanDass ChayanDass requested a review from deo002 June 23, 2025 09:02
pkg/auth/auth.go Outdated
updateActive := false
updatedUser.Active = &updateActive

if err := db.DB.Updates(&updatedUser).Error; err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use tx instead of db.DB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@ChayanDass ChayanDass force-pushed the change_logs_users branch from 75bc23b to 9e9e454 Compare July 9, 2025 10:07
AddChangelog("DisplayName", oldUser.DisplayName, newUser.DisplayName, &changes)
AddChangelog("UserEmail", oldUser.UserEmail, newUser.UserEmail, &changes)
AddChangelog("UserLevel", oldUser.UserLevel, newUser.UserLevel, &changes)
AddChangelog("UserPassword", oldUser.UserPassword, newUser.UserPassword, &changes)
Copy link
Collaborator

@deo002 deo002 Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not add password changes to changelogs. It will be a security issue.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should I totally remove the password field or add mask '****'. Else for password change logs will not create

Copy link
Collaborator

@deo002 deo002 Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally remove it. Changing password should be a personal thing and logs shouldn't be generated for it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i changed that and working as expected ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
create -> update ->delete

@ChayanDass ChayanDass force-pushed the change_logs_users branch 2 times, most recently from 1dab160 to 91f42ff Compare July 9, 2025 18:56
@deo002
Copy link
Collaborator

deo002 commented Jul 10, 2025

Found error on testing. Internal server error on passing empty object to PATCH request:

curl -X 'PATCH'
'http://localhost:5000/api/v1/users/fossy-test3'
-H 'accept: application/json'
-H 'Authorization: Bearer xyz'
-H 'Content-Type: application/json'
-d '{

}'

@ChayanDass
Copy link
Author

Found error on testing. Internal server error on passing empty object to PATCH request:

curl -X 'PATCH' 'http://localhost:5000/api/v1/users/fossy-test3' -H 'accept: application/json' -H 'Authorization: Bearer xyz' -H 'Content-Type: application/json' -d '{

}'

yes, done!

image

@ChayanDass ChayanDass requested a review from deo002 July 10, 2025 09:51
pkg/auth/auth.go Outdated
}
updatedUser.Id = olduser.Id
// update the user in the database
if err := tx.Clauses(clause.Returning{}).Updates(&updatedUser).Error; err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clauses(clause.Returning{}) should be removed as we are fetching the updated user below anyhow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants