]> source.dussan.org Git - gitea.git/commitdiff
Mirror fix
authorUnknown <joe2010xtmf@163.com>
Wed, 9 Apr 2014 18:11:24 +0000 (14:11 -0400)
committerUnknown <joe2010xtmf@163.com>
Wed, 9 Apr 2014 18:11:24 +0000 (14:11 -0400)
models/oauth2.go
modules/oauth2/oauth2.go

index 4da98006708218d40ef39f8413594e7d43c29363..cde57b87b99f15520c3307e1f538a3d896126108 100644 (file)
@@ -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)
 }
index 180c52ca0a0437befa38c6cca487262644aafd56..05ae4606a540bea49525e1195d66ebc0b108cbd5 100644 (file)
@@ -1,16 +1,7 @@
 // Copyright 2014 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// 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 oauth2 contains Martini handlers to provide
 // user login via an OAuth 2.0 backend.