// GetUserByEmail will retrieve the complete user information by email
426177
func (api *Client) GetUserByEmail(email string) (*User, error) {
	return api.GetUserByEmailContext(context.Background(), email)
}
1194200
func (m *MarketplacePlanAccount) GetEmail() string {
	if m == nil || m.Email == nil {
		return ""
	}
	return *m.Email
}
566936
func UserFilterByEmail(email string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("email = ?", email)
	}
}
1347484
func (b *bitbucketConnector) userEmail(ctx context.Context, client *http.Client) (string, error) {
	apiURL := b.apiURL + "/user/emails"
	for {
		// https://developer.atlassian.com/bitbucket/api/2/reference/resource/user/emails
		var response userEmailResponse

		if err := get(ctx, client, apiURL, &response); err != nil {
			return "", err
		}

		for _, email := range response.Values {
			if email.IsConfirmed && email.IsPrimary {
				return email.Email, nil
			}
		}

		if response.Next == nil {
			break
		}
	}

	return "", errors.New("bitbucket: user has no confirmed, primary email")
}
106161
func getUser(storage Storage, email string) (User, error) {
	var user User

	// open user reg
	userData, err := storage.LoadUser(email)
	if err != nil {
		if _, ok := err.(ErrNotExist); ok {
			// create a new user
			return newUser(email)
		}
		return user, err
	}

	// load user information
	err = json.Unmarshal(userData.Reg, &user)
	if err != nil {
		return user, err
	}

	// load their private key
	user.key, err = loadPrivateKey(userData.Key)
	return user, err
}
733946
func (g *Generic) getPrimaryEmail(client *http.Client) (string, error) {
	emailsEndpoint := g.APIURL + "/emails"
	r, err := client.Get(emailsEndpoint)
	if err != nil {
		return "", err
	}
	defer r.Body.Close()

	emails := []*UserEmail{}
	if err = json.NewDecoder(r.Body).Decode(&emails); err != nil {
		return "", err
	}

	email, err := g.primaryEmail(emails)
	if err != nil {
		g.Logger.Error("Unable to retrieve primary email ", err.Error())
		return "", err
	}
	return email, nil
}
852405
func (c *Client) FindUserByName(ctx context.Context, n string) (*platform.User, error) {
	var u *platform.User

	err := c.db.View(func(tx *bolt.Tx) error {
		usr, pe := c.findUserByName(ctx, tx, n)
		if pe != nil {
			return pe
		}
		u = usr
		return nil
	})

	return u, err
}
93200
func (auth *Auth) GetUserByEmail(ctx context.Context, email string) (*UserRecord, error) {
	users, err := auth.GetUsersByEmail(ctx, []string{email})
	if err != nil {
		return nil, err
	}
	if len(users) == 0 {
		return nil, ErrUserNotFound
	}
	return users[0], nil
}
612627
func (s *userService) GetByID(id int64) (datamodels.User, bool) {
	return s.repo.Select(func(m datamodels.User) bool {
		return m.ID == id
	})
}
536482
func (db *DynamoDB) GetByEmail(email string) (u *models.User, ok bool) {
	res, err := db.DB.Query(&dynamodb.QueryInput{
		// ConsistentRead: aws.Bool(true),
		TableName:              aws.String("users"),
		IndexName:              aws.String("Email"),
		Select:                 aws.String("ALL_ATTRIBUTES"),
		KeyConditionExpression: aws.String("Email = :Email"),
		ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
			":Email": {
				S: aws.String(email),
			},
		},
	})
	if err != nil {
		log.Printf("dynamodb: getbymail error: %v", err)
		return nil, false
	}

	var user models.User
	if err := dynamodbattribute.UnmarshalMap(res.Items[0], &user); err != nil {
		log.Printf("dynamodb: getbyid error: %v", err)
		return nil, false
	}

	return &user, true
}
349522
func GetUserByLoginOrEmail(c *m.ReqContext) Response {
	query := m.GetUserByLoginQuery{LoginOrEmail: c.Query("loginOrEmail")}
	if err := bus.Dispatch(&query); err != nil {
		if err == m.ErrUserNotFound {
			return Error(404, m.ErrUserNotFound.Error(), nil)
		}
		return Error(500, "Failed to get user", err)
	}
	user := query.Result
	result := m.UserProfileDTO{
		Id:             user.Id,
		Name:           user.Name,
		Email:          user.Email,
		Login:          user.Login,
		Theme:          user.Theme,
		IsGrafanaAdmin: user.IsAdmin,
		OrgId:          user.OrgId,
	}
	return JSON(200, &result)
}
428002
func (u *User) Emails() (interface{}, error) {
	urlStr := GetApiBaseURL() + "/user/emails"
	return u.c.execute("GET", urlStr, "")
}
205095
func (c *Cache) GetUser(name string) (user services.User, err error) {
	u, err := c.usersCache.GetUser(name)
	if trace.IsNotFound(err) {
		return c.Users.GetUser(name)
	}
	return u, err
}
1217107
func (m *Manager) GetAuthorizationsByUser(username string) (authorizations []Authorization, err error) {
	err = m.getAuthorizationCollection().Find(bson.M{"username": username}).All(&authorizations)
	if authorizations == nil {
		authorizations = []Authorization{}
	}
	return
}
971186
func (auth *Auth) GetUser(ctx context.Context, uid string) (*UserRecord, error) {
	users, err := auth.GetUsers(ctx, []string{uid})
	if err != nil {
		return nil, err
	}
	if len(users) == 0 {
		return nil, ErrUserNotFound
	}
	return users[0], nil
}
766018
func (repo *repo) FindByEmail(email string) (user service.Entity, err error) {
	if err = dbconn.DB.Where("email = ?", email).First(&user).Error; err != nil {
		return service.Entity{}, err
	}
	return user, nil
}
1277070
func (c *Crowd) GetUser(user string) (User, error) {
	u := User{}

	v := url.Values{}
	v.Set("username", user)
	url := c.url + "rest/usermanagement/1/user?" + v.Encode()
	c.Client.Jar = c.cookies
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return u, err
	}
	req.SetBasicAuth(c.user, c.passwd)
	req.Header.Set("Accept", "application/xml")
	req.Header.Set("Content-Type", "application/xml")
	resp, err := c.Client.Do(req)
	if err != nil {
		return u, err
	}
	defer resp.Body.Close()

	switch resp.StatusCode {
	case 404:
		return u, fmt.Errorf("user not found")
	case 200:
		// fall through switch without returning
	default:
		return u, fmt.Errorf("request failed: %s", resp.Status)
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return u, err
	}

	err = xml.Unmarshal(body, &u)
	if err != nil {
		return u, err
	}

	return u, nil
}