Exemplo n.º 1
0
func (a *Auther) LoginUser() *models.User {
	user, err := models.GetUserById(a.id)
	if err != nil {
		return nil
	}
	return user
}
Exemplo n.º 2
0
func (form *CommentAdminForm) Valid(v *validation.Validation) {
	var err error
	if _, err = models.GetUserById(int64(form.User)); err != nil {
		v.SetError("User", "admin.not_found_by_id")
	}

	if _, err = models.GetPostById(int64(form.Post)); err != nil {
		v.SetError("Post", "admin.not_found_by_id")
	}
}
Exemplo n.º 3
0
// get user if key exist in session
func GetUserFromSession(user *models.User, sess *session.Session) bool {
	id := GetUserIdFromSession(sess)
	if id > 0 {
		if u, err := models.GetUserById(int64(id)); err == nil {
			*user = *u
			return true
		}
	}

	return false
}
Exemplo n.º 4
0
func (form *PostAdminForm) Valid(v *validation.Validation) {
	var err error
	if _, err = models.GetUserById(form.User); err != nil {
		v.SetError("User", "admin.not_found_by_id")
	}

	if _, err = models.GetUserById(form.LastReply); err != nil {
		v.SetError("LastReply", "admin.not_found_by_id")
	}

	if _, err = models.GetUserById(form.LastAuthor); err != nil {
		v.SetError("LastReply", "admin.not_found_by_id")
	}

	if _, err = models.GetTopicById(form.Topic); err != nil {
		v.SetError("Topic", "admin.not_found_by_id")
	}

	if len(i18n.GetLangByIndex(form.Lang)) == 0 {
		v.SetError("Lang", "Not Found")
	}
}