Phase 2: Subsonic REST API framework (auth, response formatting, error handling, routing) plus user permission model

This commit is contained in:
2026-08-22 23:58:54 -05:00
parent f81c8704a5
commit b5e2bf01e2
26 changed files with 1772 additions and 75 deletions
+26
View File
@@ -0,0 +1,26 @@
package auth
import (
"database/sql"
"git.noroutes.net/NoRoutes/vibetunes/internal/database"
)
// SetUserPassword hashes plaintext for native login and also stores the
// encrypted copy legacy Subsonic token authentication needs (see
// subsonic_secret.go), keeping both in sync. This is the only path that
// should ever change a user's password.
func SetUserPassword(db *sql.DB, encryptionKey []byte, userID, plaintext string) error {
hash, err := HashPassword(plaintext)
if err != nil {
return err
}
if err := database.SetUserPassword(db, userID, hash); err != nil {
return err
}
encrypted, err := EncryptPassword(encryptionKey, plaintext)
if err != nil {
return err
}
return database.SetUserSubsonicAuthSecret(db, userID, encrypted)
}