Skip to content

Commit

Permalink
将微信回调地址设置为可配置的 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash authored Mar 25, 2024
1 parent 4c26d32 commit a2d636f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/user/internal/service/wechat_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ type WechatOAuth2Service struct {
client *http.Client
}

func NewWechatService(appId, appSecret string) OAuth2Service {
func NewWechatService(appId, appSecret, redirectURL string) OAuth2Service {
return &WechatOAuth2Service{
redirectURL: url.PathEscape("https://8.meoying.com/oauth2/wechat/callback"),
redirectURL: url.PathEscape(redirectURL),
logger: elog.DefaultLogger,
client: http.DefaultClient,
appId: appId,
Expand Down
7 changes: 4 additions & 3 deletions internal/user/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ func InitHandler(db *egorm.Component, cache ecache.Cache, creators []string) *Ha

func InitWechatService() service.OAuth2Service {
type Config struct {
AppSecretID string `yaml:"appSecretID"`
AppSecretKey string `yaml:"appSecretKey"`
AppSecretID string `yaml:"appSecretID"`
AppSecretKey string `yaml:"appSecretKey"`
LoginRedirectURL string `yaml:"loginRedirectURL"`
}
var cfg Config
err := econf.UnmarshalKey("wechat", &cfg)
if err != nil {
panic(err)
}
return service.NewWechatService(cfg.AppSecretID, cfg.AppSecretKey)
return service.NewWechatService(cfg.AppSecretID, cfg.AppSecretKey, cfg.LoginRedirectURL)
}

func InitDAO(db *egorm.Component) dao.UserDAO {
Expand Down

0 comments on commit a2d636f

Please sign in to comment.