aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gogs.go2
-rw-r--r--models/oauth2.go21
-rw-r--r--modules/oauth2/oauth2.go15
3 files changed, 15 insertions, 23 deletions
diff --git a/gogs.go b/gogs.go
index 4616141e..45be7e87 100644
--- a/gogs.go
+++ b/gogs.go
@@ -19,7 +19,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true
-const APP_VER = "0.2.2.0408 Alpha"
+const APP_VER = "0.2.2.0409 Alpha"
func init() {
base.AppVer = APP_VER
diff --git a/models/oauth2.go b/models/oauth2.go
index 9a38334e..45728b0d 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"
@@ -15,8 +19,8 @@ var (
)
type Oauth2 struct {
- Id int64 `xorm:"default 1"`
- Uid int64 `xorm:"pk"` // UserId
+ Id int64
+ 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,15 @@ 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 oa, err
}
diff --git a/modules/oauth2/oauth2.go b/modules/oauth2/oauth2.go
index 180c52ca..05ae4606 100644
--- a/modules/oauth2/oauth2.go
+++ b/modules/oauth2/oauth2.go
@@ -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.