Skip to content
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

Fix: Password storage issue with PostgreSQL backend #231

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

ReeseWang
Copy link
Contributor

Description

This pull request addresses an issue where the password field of the User struct was being stored as an empty string in the PostgreSQL database, while working correctly with the SQLite backend (not sure why). The issue was caused by the custom MarshalJSON and String methods defined on the PrivateString type, which always returned an empty string.

Changes

  • Implemented custom Value and Scan methods for the PrivateString type to handle database serialization and deserialization correctly.
    • The Value method returns the actual string as a driver.Value when storing the user record in the database.
    • The Scan method properly assigns the string from the database to the PrivateString field when querying the user record.
  • The custom methods ensure that the string is stored in the PostgreSQL database, while still keeping the password/hash hidden in the JSON and string representations of the PrivateString type.

Testing

  • Verified that the password field is stored correctly in the PostgreSQL database after applying the changes.
  • Local user creation and login work normally.
  • Local user login works normally after password changed by admin.

@h44z h44z merged commit 1d862c0 into h44z:master Mar 29, 2024
4 checks passed
@h44z
Copy link
Owner

h44z commented Mar 29, 2024

thanks

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