further tidying up account service/repo

This commit is contained in:
ari melody 2026-07-31 11:04:36 +01:00
parent 32bcb894ee
commit 9e311df462
Signed by: ari
GPG key ID: CF99829C92678188
4 changed files with 26 additions and 38 deletions

View file

@ -71,7 +71,7 @@ func (repo *AccountRepositoryMemory) Create(username string, password string, em
}
// Intended for large profile updates. For smaller adjusments,
// more specialised Change* and Remove* functions should be used.
// more specialised Update* and Remove* functions should be used.
func (repo *AccountRepositoryMemory) Update(id string, username string, password string, email *string, avatarUrl *string) error {
if account, err := repo.GetByUsername(username); err != nil {
return errors.New("Failed to fetch other acccounts by username")
@ -91,7 +91,7 @@ func (repo *AccountRepositoryMemory) Update(id string, username string, password
return nil
}
func (repo *AccountRepositoryMemory) ChangeUsername(id string, username string) error {
func (repo *AccountRepositoryMemory) UpdateUsername(id string, username string) error {
if account, err := repo.GetByUsername(username); err != nil {
return errors.New("Failed to fetch other acccounts by username")
} else if account != nil && account.ID != id {
@ -105,7 +105,7 @@ func (repo *AccountRepositoryMemory) ChangeUsername(id string, username string)
account.Username = username
return nil
}
func (repo *AccountRepositoryMemory) ChangePassword(id string, password string) error {
func (repo *AccountRepositoryMemory) UpdatePassword(id string, password string) error {
account, err := repo.GetByID(id)
if err != nil { return err }
if account == nil { return errors.New("Account does not exist") }
@ -113,7 +113,7 @@ func (repo *AccountRepositoryMemory) ChangePassword(id string, password string)
account.Password = password
return nil
}
func (repo *AccountRepositoryMemory) ChangeEmail(id string, email string) error {
func (repo *AccountRepositoryMemory) UpdateEmail(id string, email string) error {
account, err := repo.GetByID(id)
if err != nil { return err }
if account == nil { return errors.New("Account does not exist") }
@ -131,7 +131,7 @@ func (repo *AccountRepositoryMemory) RemoveEmail(id string) error {
account.Email.String = ""
return nil
}
func (repo *AccountRepositoryMemory) ChangeAvatarURL(id string, avatarURL string) error {
func (repo *AccountRepositoryMemory) UpdateAvatarURL(id string, avatarURL string) error {
account, err := repo.GetByID(id)
if err != nil { return err }
if account == nil { return errors.New("Account does not exist") }
@ -182,15 +182,9 @@ func (repo *AccountRepositoryMemory) ResetFails(id string) error {
account.FailAttempts = 0
return nil
}
func (repo *AccountRepositoryMemory) Lock(id string) error {
func (repo *AccountRepositoryMemory) SetLocked(id string, locked bool) error {
account, err := repo.GetByID(id)
if err != nil { return err }
account.Locked = true
return nil
}
func (repo *AccountRepositoryMemory) Unlock(id string) error {
account, err := repo.GetByID(id)
if err != nil { return err }
account.Locked = false
account.Locked = locked
return nil
}