@@ -1452,14 +1452,19 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
1452
1452
1453
1453
// GetUserByEmail returns the user object by given e-mail if exists.
1454
1454
func GetUserByEmail (email string ) (* User , error ) {
1455
+ return GetUserByEmailContext (DefaultDBContext (), email )
1456
+ }
1457
+
1458
+ // GetUserByEmailContext returns the user object by given e-mail if exists with db context
1459
+ func GetUserByEmailContext (ctx DBContext , email string ) (* User , error ) {
1455
1460
if len (email ) == 0 {
1456
1461
return nil , ErrUserNotExist {0 , email , 0 }
1457
1462
}
1458
1463
1459
1464
email = strings .ToLower (email )
1460
1465
// First try to find the user by primary email
1461
1466
user := & User {Email : email }
1462
- has , err := x .Get (user )
1467
+ has , err := ctx . e .Get (user )
1463
1468
if err != nil {
1464
1469
return nil , err
1465
1470
}
@@ -1469,19 +1474,19 @@ func GetUserByEmail(email string) (*User, error) {
1469
1474
1470
1475
// Otherwise, check in alternative list for activated email addresses
1471
1476
emailAddress := & EmailAddress {Email : email , IsActivated : true }
1472
- has , err = x .Get (emailAddress )
1477
+ has , err = ctx . e .Get (emailAddress )
1473
1478
if err != nil {
1474
1479
return nil , err
1475
1480
}
1476
1481
if has {
1477
- return GetUserByID ( emailAddress .UID )
1482
+ return getUserByID ( ctx . e , emailAddress .UID )
1478
1483
}
1479
1484
1480
1485
// Finally, if email address is the protected email address:
1481
1486
if strings .HasSuffix (email , fmt .Sprintf ("@%s" , setting .Service .NoReplyAddress )) {
1482
1487
username := strings .TrimSuffix (email , fmt .Sprintf ("@%s" , setting .Service .NoReplyAddress ))
1483
1488
user := & User {LowerName : username }
1484
- has , err := x .Get (user )
1489
+ has , err := ctx . e .Get (user )
1485
1490
if err != nil {
1486
1491
return nil , err
1487
1492
}
0 commit comments