Пример #1
0
func GetUser(r *http.Request) (*users.User, error) {
	session, err := GetSession(r)
	if err != nil {
		return nil, err
	}
	if u, ok := session.Values["user"]; ok {
		user, err := users.GetByEmail(u.(string)).One()
		return &user, err
	}
	return nil, errors.New("unable to detect user")
}
Пример #2
0
func (w *Watcher) AddUserByString(userStr string) {
	user, err := users.GetByEmail(userStr).One()
	if err != nil {
		return
	}
	for _, u := range w.Users {
		if user.ID == u.ID {
			return
		}
	}
	w.Users = append(w.Users, user)
}