diff --git a/user-center-slack/README.md b/user-center-slack/README.md index a15e8907..ec25cf9d 100644 --- a/user-center-slack/README.md +++ b/user-center-slack/README.md @@ -6,7 +6,7 @@ ## Config -To use this plugin, you need to create [a Slack App](https://api.slack.com/quickstart) first, set the Scope and Redirect URL correctly, and copy the `Client ID`, `Client Secrect`, `Signing Secret` and `Webhook URL`. To activate the Slash Command function, you also need to set the `slash command` in your app. Here are some examples: +To use this plugin, you need to create [a Slack App](https://api.slack.com/quickstart) first, set the Scope and Redirect URL correctly, and copy the `Client ID`, `Client Secrect`, `Signing Secret` and `Webhook URL`. To activate the Slash Command function, you also need to set the `slash command` in your app. Here are default settings you can try: > Scope: chat:write, commands, groups:write, im:write, incoming-webhook, mpim:write, users:read, users:read.email > @@ -15,7 +15,7 @@ To use this plugin, you need to create [a Slack App](https://api.slack.com/quick > Slash command: > > * Command: /ask -> * Requesti URL: https://Your_Site_URL/answer/api/v1/importer/command +> * Requesti URL: https://Your_Site_URL/answer/api/v1/slack/slash > * Usage Hint: [Title][Content\][Tag1,Tag2...\] diff --git a/user-center-slack/handler.go b/user-center-slack/handler.go index aefc1da0..0ad674b0 100644 --- a/user-center-slack/handler.go +++ b/user-center-slack/handler.go @@ -57,7 +57,7 @@ func NewRespBodyData(code int, reason string, data interface{}) *RespBody { func (uc *UserCenter) BuildSlackBaseRedirectURL() string { clientID := uc.Config.ClientID log.Debug("Get client ID:", clientID) - scope := "chat:write,commands,groups:write,im:write,incoming-webhook,mpim:write,users:read,users:read.email" // 需要的权限范围 + scope := "chat:write,commands,groups:write,im:write,incoming-webhook,mpim:write,users:read,users:read.email" response_type := "code" redirect_uri := fmt.Sprintf("%s/answer/api/v1/user-center/login/callback", plugin.SiteURL()) diff --git a/user-center-slack/schema.go b/user-center-slack/schema.go index defbec26..7596fa53 100644 --- a/user-center-slack/schema.go +++ b/user-center-slack/schema.go @@ -99,3 +99,12 @@ func NewWebhookReq(content string) *WebhookReq { }, } } + +type SlackUserResponse struct { + Ok bool `json:"ok"` + User struct { + Profile struct { + Email string `json:"email"` + } `json:"profile"` + } `json:"user"` +} diff --git a/user-center-slack/slack_user_center.go b/user-center-slack/slack_user_center.go index 33f3ce8a..688d61db 100644 --- a/user-center-slack/slack_user_center.go +++ b/user-center-slack/slack_user_center.go @@ -40,15 +40,6 @@ var Info embed.FS type Importer struct{} -type SlackUserResponse struct { - Ok bool `json:"ok"` - User struct { - Profile struct { - Email string `json:"email"` - } `json:"profile"` - } `json:"user"` -} - type UserCenter struct { Config *UserCenterConfig SlackClient *SlackClient @@ -192,7 +183,6 @@ func (uc *UserCenter) LoginCallback(ctx *plugin.GinContext) (userInfo *plugin.Us //Get Email if len(info.Profile.Email) == 0 { ctx.Redirect(http.StatusFound, "/user-center/auth-failed") - ctx.Abort() return nil, fmt.Errorf("user email is empty") }