<commit_before>package db

import (
	"errors"
	"time"

	"github.com/Rugvip/bullettime/types"
)

type User struct {
	types.UserInfo
	types.UserPresence
	PasswordHash string
}

var userTable = map[string]*User{}

func GetUser(id string) *User {
	return userTable[id]
}

func CreateUser(id string) error {
	if userTable[id] != nil {
		return errors.New("user already exists")
	}
	user := new(User)
	user.Id = id
	user.LastActive = types.LastActive(time.Now())
	userTable[id] = user
	return nil
}

func UserExists(id string) error {
	if userTable[id] == nil {
		return errors.New("user not found")
	}
	return nil
}<commit_msg>db/users: make sure password hash is never leaked through json serialization<commit_after>package db

import (
	"errors"
	"time"

	"github.com/Rugvip/bullettime/types"
)

type User struct {
	types.UserInfo
	types.UserPresence
	PasswordHash string `json:"-"`
}

var userTable = map[string]*User{}

func GetUser(id string) *User {
	return userTable[id]
}

func CreateUser(id string) error {
	if userTable[id] != nil {
		return errors.New("user already exists")
	}
	user := new(User)
	user.Id = id
	user.LastActive = types.LastActive(time.Now())
	userTable[id] = user
	return nil
}

func UserExists(id string) error {
	if userTable[id] == nil {
		return errors.New("user not found")
	}
	return nil
}
{'fraction_non_alphanumeric': 0.125948406676783, 'fraction_numerical': 0.0, 'mean_word_length': 4.361788617886178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3651004', 'n_tokens_mistral': 483, 'n_tokens_neox': 472, 'n_words': 123}