This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git

commit 262cf4305578687bf7be6c427988adc0aaecfed6
Author: Anan <[email protected]>
AuthorDate: Wed Oct 16 03:06:27 2024 +0000

    Fix slack_user_center
---
 user-center-slack/README.md            |  4 ++--
 user-center-slack/handler.go           |  2 +-
 user-center-slack/schema.go            |  9 +++++++++
 user-center-slack/slack_user_center.go | 10 ----------
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/user-center-slack/README.md b/user-center-slack/README.md
index a15e890..ec25cf9 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 aefc1da..0ad674b 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 defbec2..7596fa5 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 33f3ce8..688d61d 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")
        }
 

Reply via email to