Remove password reset functionality

Backend:
- Remove ForgotPassword API handler
- Remove password reset token model and database table
- Remove email service for sending reset emails
- Remove SMTP configuration

Frontend:
- Remove /auth/forgot page
- Remove forgot password link from login page
- Remove forgot route from auth-only routes check
This commit is contained in:
Christoph Haas 2026-03-23 22:35:30 +01:00
parent c459cc1efb
commit abd7e3a97f
9 changed files with 5 additions and 425 deletions

View file

@ -1,7 +1,5 @@
package db
import "time"
// =============================================================================
// Admin User (ImcUser) Operations
// These functions manage admin users who can log into the web interface.
@ -189,40 +187,3 @@ func (d *DB) IsUserInDomain(userID, domainID uint) (bool, error) {
err := d.Model(&ImcUserDomain{}).Where("user_id = ? AND domain_id = ?", userID, domainID).Count(&count).Error
return count > 0, err
}
// =============================================================================
// Password Reset Tokens
// These functions manage one-time tokens for password reset.
// =============================================================================
// CreatePasswordResetToken creates a new password reset token.
// userID: the ID of the user requesting password reset.
// token: the random token string.
// expiresAt: when this token becomes invalid.
func (d *DB) CreatePasswordResetToken(userID uint, token string, expiresAt time.Time) error {
resetToken := PasswordResetToken{
UserID: userID,
Token: token,
ExpiresAt: expiresAt,
}
return d.Create(&resetToken).Error
}
// GetValidPasswordResetToken looks up a valid (unused, not expired) reset token.
// token: the token string to look up.
// Returns: the token if valid, or an error if not found/expired/used.
func (d *DB) GetValidPasswordResetToken(token string) (*PasswordResetToken, error) {
var resetToken PasswordResetToken
// Check token exists, hasn't been used, and hasn't expired.
err := d.Where("token = ? AND used = false AND expires_at > ?", token, time.Now()).First(&resetToken).Error
if err != nil {
return nil, err
}
return &resetToken, nil
}
// MarkResetTokenUsed marks a token as used (prevents reuse).
// token: the token string to mark as used.
func (d *DB) MarkResetTokenUsed(token string) error {
return d.Model(&PasswordResetToken{}).Where("token = ?", token).Update("used", true).Error
}