added notify helpers

This commit is contained in:
2026-01-26 13:45:17 +11:00
parent a5b92a247b
commit e47619abd4
6 changed files with 83 additions and 33 deletions

View File

@@ -18,7 +18,7 @@ import (
)
func Register(
server *hws.Server,
s *hws.Server,
auth *hwsauth.Authenticator[*db.User, bun.Tx],
conn *bun.DB,
cfg *config.Config,
@@ -42,7 +42,7 @@ func Register(
store.ClearRedirectTrack(r, "/register")
throwError(
server,
s,
w,
r,
http.StatusBadRequest,
@@ -69,7 +69,7 @@ func Register(
defer cancel()
tx, err := conn.BeginTx(ctx, nil)
if err != nil {
throwInternalServiceError(server, w, r, "Database transaction failed", err)
throwInternalServiceError(s, w, r, "Database transaction failed", err)
return
}
defer tx.Rollback()
@@ -83,7 +83,10 @@ func Register(
username := r.FormValue("username")
user, err := registerUser(ctx, tx, username, details)
if err != nil {
throwInternalServiceError(server, w, r, "Registration failed", err)
err = notifyInternalServiceError(s, r, "Registration failed", err)
if err != nil {
throwInternalServiceError(s, w, r, "Registration failed", err)
}
return
}
tx.Commit()
@@ -92,7 +95,7 @@ func Register(
} else {
err = auth.Login(w, r, user, true)
if err != nil {
throwInternalServiceError(server, w, r, "Login failed", err)
throwInternalServiceError(s, w, r, "Login failed", err)
return
}
pageFrom := cookies.CheckPageFrom(w, r)