Beispiel #1
0
func CreateUser(u *models.User, salt *models.Salts, body *user.Account) {
	u.Mail = body.Mail
	u.Name = body.Name
	u.Phone = body.Phone
	u.CreatedAt = time.Now().Unix()
	u.UpdatedAt = time.Now().Unix()
	salt.Salt = utils.EncryptRandSequence(5)
	DecodeSalt, _ := utils.TokenDecode(salt.Salt)
	u.Password, _ = utils.PsdHandler(body.Password, []byte(DecodeSalt))
}
Beispiel #2
0
func TestUserInsert(t *testing.T) {
	user := models.User{
		Name:     "liyifan",
		Mail:     "*****@*****.**",
		Phone:    "080-6761-1034",
		Password: "******",
	}
	user.CreatedAt = time.Now().Unix()
	user.UpdatedAt = time.Now().Unix()
	DB.Create(&user)
}