Skip to content

removed excess tom toolkit overwrite and added snex1 pw account deletion sync#148

Open
moira-andrews wants to merge 2 commits intodevfrom
fix_user_pw_registration
Open

removed excess tom toolkit overwrite and added snex1 pw account deletion sync#148
moira-andrews wants to merge 2 commits intodevfrom
fix_user_pw_registration

Conversation

@moira-andrews
Copy link
Collaborator

@moira-andrews moira-andrews commented Feb 4, 2026

Mostly cleaned up registration functionality to pull as much as possible from base tom toolkit. Refactored the sync_users_with_snex1 to include the snex1 password. This hook is run on user login, so it will update the snex1 database with a new password hash each time a user logs in. So when a new user registers an account on snex2, they will have a working snex1 account after they log into snex2 for the first time. This also works for any group or user account changes on snex2, they are updated and reflected on snex1 on next snex2 login.

I also added functionality to delete accounts, which functions similarly to the comment deletion implemented in #138. When a user is deleted, they are also deleted from the supernovadb Users table.

Test by spinning up a local installation of snexdev with snex1 and snex2, create a user in snex2, approve the user, and login. Then open up the local snex1 and ensure the new user can login. Also test existing users by logging into both snex1 and snex2 and ensuring success on both ends.

If testing on the small database, make sure to add the snex2 admin account to a group and re-signing in. Otherwise the snex1 user list page won't display correctly because there is a user with no group.

Before merging, logging statements need to be removed.

Copy link
Collaborator

@crpellegrino crpellegrino left a comment

Choose a reason for hiding this comment

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

Nice job! Here's a couple mostly high-level comments to consider


return encpw

@receiver(user_logged_in)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be a dumb question, but does this run every time the user logs in, or just the first time? Doing this every time is probably overkill

Comment on lines +940 to +942
if delete:
db_session.query(Users).filter(Users.name == user.username).delete()
logger.info(f'User {user.username} deleted from SNEx1')
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does deleting users work in SNEx1? I don't know if I've ever done it, so not sure what the implications would be on anything that's connected to the user. Hopefully not a cascading delete on things like observation sequences, targets, etc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a great point, I haven't tested it with that, I'll need to go through and check this.

@moira-andrews
Copy link
Collaborator Author

I've tested deleting functionality with comments and uploaded spectra. On SNEx2, the spectrum and comments persist, but on SNEx1, the spectrum and comments no longer appear.

image image

The deleted user also doesn't show up under interested persons on SNEx2. Papers Status does persist after account deletion.

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