summaryrefslogtreecommitdiffstats
path: root/models/oauth2.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-04-09 14:11:24 -0400
committerUnknown <joe2010xtmf@163.com>2014-04-09 14:11:24 -0400
commita773cf1d876d59ab036ebf8a6843bf78da83531e (patch)
treea09ff41911f76215a6af66c2dcdeb4a6bbd127ab /models/oauth2.go
parenta991ebf5d0fe06c97be4b90b562e058ea2642de9 (diff)
downloadgitea-a773cf1d876d59ab036ebf8a6843bf78da83531e.tar.gz
gitea-a773cf1d876d59ab036ebf8a6843bf78da83531e.zip
Mirror fix
Diffstat (limited to 'models/oauth2.go')
-rw-r--r--models/oauth2.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/models/oauth2.go b/models/oauth2.go
index 4da9800670..cde57b87b9 100644
--- a/models/oauth2.go
+++ b/models/oauth2.go
@@ -1,3 +1,7 @@
+// Copyright 2014 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
package models
import "errors"
@@ -16,7 +20,7 @@ var (
type Oauth2 struct {
Id int64
- Uid int64 `xorm:"pk"` // userId
+ Uid int64 // userId
User *User `xorm:"-"`
Type int `xorm:"pk unique(oauth)"` // twitter,github,google...
Identity string `xorm:"pk unique(oauth)"` // id..
@@ -31,18 +35,14 @@ func AddOauth2(oa *Oauth2) (err error) {
}
func GetOauth2(identity string) (oa *Oauth2, err error) {
- oa = &Oauth2{}
- oa.Identity = identity
- exists, err := orm.Get(oa)
+ oa = &Oauth2{Identity: identity}
+ isExist, err := orm.Get(oa)
if err != nil {
return
- }
- if !exists {
+ } else if !isExist {
return nil, ErrOauth2RecordNotExists
- }
- if oa.Uid == 0 {
+ } else if oa.Uid == 0 {
return oa, ErrOauth2NotAssociatedWithUser
}
- oa.User, err = GetUserById(oa.Uid)
- return
+ return GetUserById(oa.Uid)
}