Пример #1
0
// Current returns the current users password object minus the password
func (s *Service) Current(w http.ResponseWriter, r *http.Request,
	args *Args, reply *Args) (err error) {

	c := context.NewContext(r)
	var isSet bool
	userID, _ := user.CurrentUserID(r)
	_, err = profile.Get(c, profile.GenAuthID("Password", userID))
	if err == nil {
		isSet = true
	}
	reply.Password = &Password{IsSet: isSet}
	return nil
}
Пример #2
0
func login(c appengine.Context, pass string, userID string) (
	pf *profile.Profile, err error) {

	if userID == "" {
		return nil, ErrProfileNotFound
	}
	pid := profile.GenAuthID("Password", userID)
	if pf, err = profile.Get(c, pid); err != nil {
		return nil, ErrProfileNotFound
	}
	if err := CompareHashAndPassword(pf.Auth, []byte(pass)); err != nil {
		return nil, err
	}
	return pf, nil
}