refactor(api): one password rule, one hash, one unique-violation check (#8002)
The length check and bcrypt call were copied into sign-up, reset, change and both admin paths; the unique-violation test into three api handlers and the library. checkNewPassword and hashPassword now sit in api/prelude.go, and db.IsUniqueViolation serves api and library. The taken-username and taken-email conflicts now carry a message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
||||
)
|
||||
|
||||
@@ -99,7 +100,7 @@ func (s *Scanner) SetRoots(ctx context.Context, changes []RootChange) (RerootRes
|
||||
for _, m := range moves {
|
||||
n, err := tq.RerootTrackPaths(ctx, dbq.RerootTrackPathsParams{NewRoot: m.Path, OldRoot: m.Was})
|
||||
if err != nil {
|
||||
if isUniqueViolation(err) {
|
||||
if db.IsUniqueViolation(err) {
|
||||
return badRoots("Some tracks under %s are already in the library at %s, "+
|
||||
"so its tracks cannot move there.", m.Was, m.Path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user