package models

import (
	"strings"

	"github.com/jinzhu/gorm"
)

// User represent a system user
type User struct {
	gorm.Model
	Name     string    `gorm:"type:varchar(50)"`
	Username string    `gorm:"type:varchar(35);unique"`
	Passwd   string    `gorm:"type:varchar(255);unique"`
	Requests []Request `gorm:"foreign_key:UserID"`
}

// CreateUser create a user
func CreateUser(u *User) error {
	u.Name = strings.ToTitle(u.Name)
	return nil
}

func EncodePasswd(u *User) {

}
