Ejemplo n.º 1
0
func Test_ValidUserAdd(t *testing.T) {
	user := models.User{Username: "******", Password: "******"}
	var valid *validation.Validation
	valid = user.ValidUserAdd()
	b, _ := valid.Valid(user)
	if !b {
		for k, v := range valid.ErrorMap() {
			beego.Info(k, " Error is ", "-", v.Value, "-", v.Field, "-", v.Tmpl, "-", v.Key, "=")
		}
	}

}
Ejemplo n.º 2
0
// 登录
func (as *AuthService) Login(user *models.User) map[string]string {
	data := user.Login()
	for k, _ := range data {
		if strings.Contains(k, "Error") {
			return data
		}
	}

	as.Factory().CookieService.WithContext(as.ctx, func() {
		var rolestr = fmt.Sprintf("%s", user.Role)
		var value = utils.DES().Encrypt(fUsername + seq + user.Id + seq + rolestr + seq + user.Username)
		as.Factory().CookieService.SetWithT(authUsername, value, c_timeout)
	})
	return data
}
Ejemplo n.º 3
0
func Test_SelectOneById(t *testing.T) {
	user := new(models.User).SelectOneById("pk_2")
	t.Log(user.ToString())
}