package db import ( log "github.com/sirupsen/logrus" "golang.org/x/crypto/bcrypt" "reichard.io/imagini/graph/model" ) func (dbm *DBManager) CreateUser(user *model.User) error { log.Info("[db] Creating user: ", user.Username) hashedPassword, err := bcrypt.GenerateFromPassword([]byte(*user.Password), bcrypt.DefaultCost) if err != nil { log.Error(err) return err } stringHashedPassword := string(hashedPassword) user.Password = &stringHashedPassword return dbm.db.Create(user).Error } func (dbm *DBManager) User(user *model.User) (int64, error) { var count int64 err := dbm.db.Where(user).First(user).Count(&count).Error return count, err } func (dbm *DBManager) Users() ([]*model.User, int64, error) { var foundUsers []*model.User var count int64 err := dbm.db.Find(&foundUsers).Count(&count).Error return foundUsers, count, err } func (dbm *DBManager) DeleteUser(user model.User) error { return nil } func (dbm *DBManager) UpdatePassword(user model.User, pw string) { }