aboutsummaryrefslogtreecommitdiffstats
path: root/models/twofactor.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-06-18 01:50:11 +0800
committerGitHub <noreply@github.com>2020-06-17 20:50:11 +0300
commit1645d4a5d8def3cc5451e068aa0a321e028a889b (patch)
tree99e1f29ec2dbb568cfee090ea4a2e49dfca02280 /models/twofactor.go
parent61cd0ce86601a0bffb625ae27a7b76ee8a15cb36 (diff)
downloadgitea-1645d4a5d8def3cc5451e068aa0a321e028a889b.tar.gz
gitea-1645d4a5d8def3cc5451e068aa0a321e028a889b.zip
Use ID or Where to instead directly use Get when load object from database (#11925)
* Use ID or Where to instead directly use Get when load object from database * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/twofactor.go')
-rw-r--r--models/twofactor.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/models/twofactor.go b/models/twofactor.go
index 00a465353a..888c910b94 100644
--- a/models/twofactor.go
+++ b/models/twofactor.go
@@ -142,8 +142,8 @@ func UpdateTwoFactor(t *TwoFactor) error {
// GetTwoFactorByUID returns the two-factor authentication token associated with
// the user, if any.
func GetTwoFactorByUID(uid int64) (*TwoFactor, error) {
- twofa := &TwoFactor{UID: uid}
- has, err := x.Get(twofa)
+ twofa := &TwoFactor{}
+ has, err := x.Where("uid=?", uid).Get(twofa)
if err != nil {
return nil, err
} else if !has {