// FindUserWithCredential returns user associated with username and password.
func (d *DefaultMongoStore) FindUserWithCredential(username string, password string) User {
	/* Condition validation */
	if len(username) == 0 || len(password) == 0 {
		return nil
	}

	user := new(DefaultUser)
	if err := mongo.EntityWithCriteria(TableUser, bson.M{"username": username}, user); err == nil && util.ComparePassword(user.Pass, password) {
		return user
	}
	return nil
}
// FindUserWithClient returns user associated with client_id and client_secret.
func (d *DefaultMongoStore) FindUserWithClient(clientID string, clientSecret string) User {
	/* Condition validation */
	if len(clientID) == 0 || len(clientSecret) == 0 {
		return nil
	}

	user := new(DefaultUser)
	if err := mongo.EntityWithID(TableUser, bson.ObjectIdHex(clientID), user); err == nil && util.ComparePassword(user.Pass, clientSecret) {
		return user
	}
	return nil
}