// AddUser adds a user to the storage if it is not already there.
AddUser adds a user to the storage if it is not already there.
// AddUser adds a user to the storage if it is not already there .
func (s *DB) AddOrAuthUser(name, password string) error {
	s.mu.Lock()
	defer s.mu.Unlock()
	if password == "" {
		return errors.New("password cannot be empty")
	}
	if storedHash, has := s.credentials[name]; has {
		if storedHash != hash(password) {
			return errors.New("wrong password")
		}
		return nil
	}
	s.credentials[name] = hash(password)
	return nil
}
func ( s * DB ) AddOrAuthUser ( name , password string ) error { s . mu . Lock ( ) defer s . mu . Unlock ( ) if password == " " { return errors . New ( " " ) } if storedHash , has := s . credentials [ name ] ; has { if storedHash != hash ( password ) { return errors . New ( " " ) } return nil } s . credentials [ name ] = hash ( password ) return nil }
AddUser adds a user to the storage if it is not already there.
AddUser adds a user to the storage if it is not already there .