Skip to content

Commit

Permalink
remove file
Browse files Browse the repository at this point in the history
  • Loading branch information
pyama86 committed Nov 6, 2020
1 parent 00cc0f3 commit 8e437fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REVISION := $(shell git rev-parse --short HEAD)
INFO_COLOR=\033[1;34m
RESET=\033[0m
BOLD=\033[1m
TEST ?= $(shell go list ./... | grep -v -e vendor -e keys -e tmp)
TEST ?= $(shell go list ./... | grep -v -e vendor -e keys -e tmp -e example)

GOVERSION=$(shell go version)
GO ?= GO111MODULE=on go
Expand Down
18 changes: 10 additions & 8 deletions libstns/stns.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type STNS struct {
opt *Options
makeChallengeCode func() ([]byte, error)
storeChallengeCode func(string, []byte) error
getChallengeCode func(string) ([]byte, error)
popChallengeCode func(string) ([]byte, error)
}

func DefaultStoreChallengeCode(user string, code []byte) error {
Expand All @@ -33,8 +33,10 @@ func DefaultStoreChallengeCode(user string, code []byte) error {
return nil
}

func DefaultGetChallengeCode(user string) ([]byte, error) {
return ioutil.ReadFile(path.Join(os.TempDir(), user))
func DefaultPopChallengeCode(user string) ([]byte, error) {
p := path.Join(os.TempDir(), user)
defer os.Remove(p)
return ioutil.ReadFile(p)
}

func DefaultMakeChallengeCode() ([]byte, error) {
Expand Down Expand Up @@ -73,7 +75,7 @@ func NewSTNS(endpoint string, opt *Options) (*STNS, error) {
}

s := &STNS{
getChallengeCode: DefaultGetChallengeCode,
popChallengeCode: DefaultPopChallengeCode,
storeChallengeCode: DefaultStoreChallengeCode,
makeChallengeCode: DefaultMakeChallengeCode,
}
Expand All @@ -96,8 +98,8 @@ func (s *STNS) SetStoreChallengeCode(f func(string, []byte) error) {
s.storeChallengeCode = f
}

func (s *STNS) SetGetChallengeCode(f func(string) ([]byte, error)) {
s.getChallengeCode = f
func (s *STNS) SetPopChallengeCode(f func(string) ([]byte, error)) {
s.popChallengeCode = f
}

func (s *STNS) ListUser() ([]*model.User, error) {
Expand Down Expand Up @@ -189,8 +191,8 @@ func (c *STNS) CreateUserChallengeCode(name string) ([]byte, error) {
return code, nil
}

func (c *STNS) GetUserChallengeCode(name string) ([]byte, error) {
return c.getChallengeCode(name)
func (c *STNS) PopUserChallengeCode(name string) ([]byte, error) {
return c.popChallengeCode(name)
}

func (c *STNS) Sign(code []byte) ([]byte, error) {
Expand Down

0 comments on commit 8e437fa

Please sign in to comment.