OSDN Git Service
(root)
/
bytom
/
vapor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
validateBlock unit test (#346)
[bytom/vapor.git]
/
accesstoken
/
accesstoken.go
diff --git
a/accesstoken/accesstoken.go
b/accesstoken/accesstoken.go
index
7f87270
..
640f4ae
100644
(file)
--- a/
accesstoken/accesstoken.go
+++ b/
accesstoken/accesstoken.go
@@
-10,9
+10,8
@@
import (
"strings"
"time"
"strings"
"time"
- dbm "github.com/tendermint/tmlibs/db"
-
"github.com/vapor/crypto/sha3pool"
"github.com/vapor/crypto/sha3pool"
+ dbm "github.com/vapor/database/leveldb"
"github.com/vapor/errors"
)
"github.com/vapor/errors"
)
@@
-73,7
+72,6
@@
func (cs *CredentialStore) Create(id, typ string) (*Token, error) {
hashedSecret := make([]byte, tokenSize)
sha3pool.Sum256(hashedSecret, secret)
hashedSecret := make([]byte, tokenSize)
sha3pool.Sum256(hashedSecret, secret)
-
token := &Token{
ID: id,
Token: fmt.Sprintf("%s:%x", id, hashedSecret),
token := &Token{
ID: id,
Token: fmt.Sprintf("%s:%x", id, hashedSecret),
@@
-85,8
+83,8
@@
func (cs *CredentialStore) Create(id, typ string) (*Token, error) {
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
- cs.DB.Set(key, value)
+ cs.DB.Set(key, value)
return token, nil
}
return token, nil
}
@@
-96,12
+94,12
@@
func (cs *CredentialStore) Check(id string, secret string) error {
return errors.WithDetailf(ErrBadID, "invalid id %q", id)
}
return errors.WithDetailf(ErrBadID, "invalid id %q", id)
}
- var value []byte
- token := &Token{}
-
- if value = cs.DB.Get([]byte(id)); value == nil {
+ value := cs.DB.Get([]byte(id))
+ if value == nil {
return errors.WithDetailf(ErrNoMatchID, "check id %q nonexisting", id)
}
return errors.WithDetailf(ErrNoMatchID, "check id %q nonexisting", id)
}
+
+ token := &Token{}
if err := json.Unmarshal(value, token); err != nil {
return err
}
if err := json.Unmarshal(value, token); err != nil {
return err
}