Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
it512 committed Nov 16, 2024
1 parent 2ba4efa commit 774c6ed
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 21 deletions.
10 changes: 5 additions & 5 deletions wxlogin/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ module wxlogin
go 1.23.1

require (
github.com/Khan/genqlient v0.7.0
github.com/go-jose/go-jose/v4 v4.0.4
github.com/google/uuid v1.6.0
github.com/it512/box v0.0.2
github.com/mailru/easyjson v0.7.7
github.com/tinylib/msgp v1.2.0
github.com/it512/box v0.0.3
github.com/twiglab/crm/member v0.0.0-20241116061244-2ba4efae26f1
github.com/twiglab/crm/wechat v0.0.0-20241116061244-2ba4efae26f1
)

require (
github.com/josharian/intern v1.0.0 // indirect
github.com/philhofer/fwd v1.1.3-0.20240612014219-fbbf4953d986 // indirect
github.com/vektah/gqlparser/v2 v2.5.19 // indirect
golang.org/x/crypto v0.28.0 // indirect
)
24 changes: 14 additions & 10 deletions wxlogin/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-jose/go-jose/v4 v4.0.4 h1:VsjPI33J0SB9vQM6PLmNjoHqMQNGPiZ0rHL7Ni7Q6/E=
Expand All @@ -6,20 +10,20 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/it512/box v0.0.2 h1:GcarlBnJP//sNQvAidhxUYe/XBBJNqsN1veYIf+pS7Y=
github.com/it512/box v0.0.2/go.mod h1:+fcLs8t3UltEzD1HQpqVt3O9UgTVnTqzXBFpYcIHWVU=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/philhofer/fwd v1.1.3-0.20240612014219-fbbf4953d986 h1:jYi87L8j62qkXzaYHAQAhEapgukhenIMZRBKTNRLHJ4=
github.com/philhofer/fwd v1.1.3-0.20240612014219-fbbf4953d986/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/it512/box v0.0.3 h1:I0Ip6hrWT6ZGM7MQ7lhjyMZaRFj64N+8XhtHFaN5dk0=
github.com/it512/box v0.0.3/go.mod h1:DCOijMT58jkk2xbW2pNAP4GpdBv4GlBUcBflf7gw8S8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tinylib/msgp v1.2.0 h1:0uKB/662twsVBpYUPbokj4sTSKhWFKB7LopO2kWK8lY=
github.com/tinylib/msgp v1.2.0/go.mod h1:2vIGs3lcUo8izAATNobrCHevYZC/LMsJtw4JPiYPHro=
github.com/twiglab/crm/member v0.0.0-20241116061244-2ba4efae26f1 h1:JnPUqp1Jgrxr2IpHV4QJ/6tHbCEdSSt2p4pm12nGqRE=
github.com/twiglab/crm/member v0.0.0-20241116061244-2ba4efae26f1/go.mod h1:dV6ntWKUnXXLbCzYkNU2d1jjD9FKUOcZon1SJ+X20xo=
github.com/twiglab/crm/wechat v0.0.0-20241116061244-2ba4efae26f1 h1:wjngLNRqau18Vqn6ybCn4Ws2U1fwehXrQJ0sEWLDsh8=
github.com/twiglab/crm/wechat v0.0.0-20241116061244-2ba4efae26f1/go.mod h1:gXsub5c9PNnxisPDWoDkAwKrt99MeUYgAb0ehGZRyTk=
github.com/vektah/gqlparser/v2 v2.5.19 h1:bhCPCX1D4WWzCDvkPl4+TP1N8/kLrWnp43egplt7iSg=
github.com/vektah/gqlparser/v2 v2.5.19/go.mod h1:y7kvl5bBlDeuWIvLtA9849ncyvx6/lj06RsMrEjVy3U=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
6 changes: 0 additions & 6 deletions wxlogin/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ func Auth(config AuthJWTConfig) http.HandlerFunc {
}

ctx := r.Context()
az := box.MustFrom[*Authz](ctx, AzKey)
u, err := az.Login(ctx, code, passwd)
if err != nil {
http.Error(w, "Not found user", http.StatusUnauthorized)
return
}

token := NewClaims(u.Code)
tokenString, err := signed(token, secret)
Expand Down
24 changes: 24 additions & 0 deletions wxlogin/wx/client.go
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
package wx

import (
"context"

"github.com/Khan/genqlient/graphql"
"github.com/twiglab/crm/member/pkg/data"
"github.com/twiglab/crm/member/pkg/low"
)

type MemberCli struct {
client graphql.Client
}

func NewMemberCli(client graphql.Client) *MemberCli {
return &MemberCli{client: client}
}

func (c *MemberCli) Add(ctx context.Context, wxOpenID string) error {
_, err := low.QueryWxMember(ctx, c.client, data.OpenIDReq{WxOpenID: wxOpenID})
if err != nil {
return err
}
return nil
}
21 changes: 21 additions & 0 deletions wxlogin/wx/wx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package wx

import (
"context"

"github.com/Khan/genqlient/graphql"
"github.com/twiglab/crm/wechat/pkg/data"
"github.com/twiglab/crm/wechat/pkg/low"
)

type WxCli struct {
client graphql.Client
}

func (c *WxCli) AuthUser(ctx context.Context, jsCode string) error {
_, err := low.AuthUser(ctx, c.client, data.JsCodeReq{JsCode: jsCode})
if err != nil {
return err
}
return nil
}

0 comments on commit 774c6ed

Please sign in to comment.