Merge branch 'main' of https://repos.gfranz.ch/Gabriel20xx/CollabTable
Docker / Docker Build & Push (push) Successful in 3m30s

This commit is contained in:
Gabriel20xx committed 2026-08-27 13:44:16 +02:00
commit ba7dfeac31
1 file changed
+6 -6
+6 -6
View File
@@ -238,7 +238,7 @@ func (a *AuthService) handleResetConfirm(w http.ResponseWriter, r *http.Request)
return return
} }
if !a.reset.Confirm(request.Code) { if !a.reset.Confirm(request.Code) {
writeJSONError(w, http.StatusUnauthorized, "Invalid or expired code") writeJSONError(w, http.StatusUnauthorized, "Invalid or expired reset code.")
return return
} }
if err := a.db.deleteAllUsers(r.Context()); err != nil { if err := a.db.deleteAllUsers(r.Context()); err != nil {
@@ -331,7 +331,7 @@ func (a *AuthService) handleLogin(w http.ResponseWriter, r *http.Request) {
return return
} }
if user.TOTPEnabled && !sharedauth.VerifyTOTP(user.TOTPSecret, request.TotpToken, time.Now()) { if user.TOTPEnabled && !sharedauth.VerifyTOTP(user.TOTPSecret, request.TotpToken, time.Now()) {
writeJSONError(w, http.StatusUnauthorized, "two-factor authentication code required") writeJSONError(w, http.StatusUnauthorized, "Two-factor authentication code required.")
return return
} }
if err := a.startSession(r.Context(), w, user.ID); err != nil { if err := a.startSession(r.Context(), w, user.ID); err != nil {
@@ -382,7 +382,7 @@ func (a *AuthService) handleTOTPEnable(w http.ResponseWriter, r *http.Request, u
} }
secret, _, err := a.db.getTOTPState(r.Context(), user.ID) secret, _, err := a.db.getTOTPState(r.Context(), user.ID)
if err != nil || !sharedauth.VerifyTOTP(secret, request.Token, time.Now()) { if err != nil || !sharedauth.VerifyTOTP(secret, request.Token, time.Now()) {
writeJSONError(w, http.StatusUnauthorized, "invalid two-factor authentication code") writeJSONError(w, http.StatusUnauthorized, "Invalid authenticator code.")
return return
} }
if err := a.db.enableTOTP(r.Context(), user.ID); err != nil { if err := a.db.enableTOTP(r.Context(), user.ID); err != nil {
@@ -400,7 +400,7 @@ func (a *AuthService) handleTOTPDisable(w http.ResponseWriter, r *http.Request,
} }
secret, enabled, err := a.db.getTOTPState(r.Context(), user.ID) secret, enabled, err := a.db.getTOTPState(r.Context(), user.ID)
if err != nil || !enabled || !sharedauth.VerifyTOTP(secret, request.Token, time.Now()) { if err != nil || !enabled || !sharedauth.VerifyTOTP(secret, request.Token, time.Now()) {
writeJSONError(w, http.StatusUnauthorized, "invalid two-factor authentication code") writeJSONError(w, http.StatusUnauthorized, "Invalid authenticator code.")
return return
} }
if err := a.db.disableTOTP(r.Context(), user.ID); err != nil { if err := a.db.disableTOTP(r.Context(), user.ID); err != nil {
@@ -579,7 +579,7 @@ func (a *AuthService) handleUsers(w http.ResponseWriter, r *http.Request, actor
} }
created, err := a.db.createManagedUser(r.Context(), username, email, string(hash), role) created, err := a.db.createManagedUser(r.Context(), username, email, string(hash), role)
if err != nil { if err != nil {
writeJSONError(w, http.StatusConflict, "Username or email is already in use") writeJSONError(w, http.StatusConflict, "Username or email is already in use.")
return return
} }
writeJSON(w, http.StatusCreated, managedUserView(*created)) writeJSON(w, http.StatusCreated, managedUserView(*created))
@@ -652,7 +652,7 @@ func (a *AuthService) handleUser(w http.ResponseWriter, r *http.Request, actor *
role = string(sharedauth.NormalizeRole(*request.Role)) role = string(sharedauth.NormalizeRole(*request.Role))
} }
if err := a.db.updateManagedUser(r.Context(), id, username, email, passwordHash, role); err != nil { if err := a.db.updateManagedUser(r.Context(), id, username, email, passwordHash, role); err != nil {
writeJSONError(w, http.StatusConflict, "Username or email is already in use") writeJSONError(w, http.StatusConflict, "Username or email is already in use.")
return return
} }
writeJSON(w, http.StatusOK, map[string]bool{"ok": true}) writeJSON(w, http.StatusOK, map[string]bool{"ok": true})