Skip to content

Commit

Permalink
Merge pull request #4 from LyricTian/dev
Browse files Browse the repository at this point in the history
修复令牌存储
  • Loading branch information
LyricTian committed May 30, 2016
2 parents 97203d1 + 6a655af commit 4877b08
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tokenMongoStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewTokenMongoStore(mongoConfig *MongoConfig, cName string) (TokenStore, err
if cName == "" {
cName = DefaultTokenCollectionName
}
err = mHandler.C(cName).EnsureIndexKey("ID", "AccessToken", "RefreshToken")
err = mHandler.C(cName).EnsureIndexKey("AccessToken", "RefreshToken")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -58,7 +58,7 @@ func (tm *TokenMongoStore) Create(item *Token) (id int64, err error) {
// Update Modify item
func (tm *TokenMongoStore) Update(id int64, info map[string]interface{}) (err error) {
tm.mHandler.CHandle(tm.cName, func(c *mgo.Collection) {
err = c.Update(bson.M{"ID": id}, bson.M{"$set": info})
err = c.UpdateId(id, bson.M{"$set": info})
if err != nil {
return
}
Expand All @@ -69,7 +69,7 @@ func (tm *TokenMongoStore) Update(id int64, info map[string]interface{}) (err er
func (tm *TokenMongoStore) findOne(query interface{}) (token *Token, err error) {
tm.mHandler.CHandle(tm.cName, func(c *mgo.Collection) {
var result []Token
err = c.Find(query).Sort("-ID").Limit(1).All(&result)
err = c.Find(query).Sort("-_id").Limit(1).All(&result)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion tokenStore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

// Token 令牌信息
type Token struct {
ID int64 `bson:"ID"` // 唯一标识(自增ID)
ID int64 `bson:"_id"` // 唯一标识(自增ID)
ClientID string `bson:"ClientID"` // 客户端标识
UserID string `bson:"UserID"` // 用户标识
AccessToken string `bson:"AccessToken"` // 访问令牌
Expand Down

0 comments on commit 4877b08

Please sign in to comment.