mirror of
https://github.com/songquanpeng/message-pusher.git
synced 2025-10-06 08:36:58 +08:00
fix: update push setting prompts
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"message-pusher/common"
|
||||
"message-pusher/model"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetStatus(c *gin.Context) {
|
||||
@@ -171,23 +167,3 @@ func ResetPassword(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func WeChatTestAccountVerification(c *gin.Context) {
|
||||
user := model.User{Username: c.Param("username")}
|
||||
user.FillUserByUsername()
|
||||
// https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html
|
||||
signature := c.Query("signature")
|
||||
timestamp := c.Query("timestamp")
|
||||
nonce := c.Query("nonce")
|
||||
echoStr := c.Query("echostr")
|
||||
arr := []string{user.WeChatTestAccountVerificationToken, timestamp, nonce}
|
||||
sort.Strings(arr)
|
||||
str := strings.Join(arr, "")
|
||||
hash := sha1.Sum([]byte(str))
|
||||
hexStr := hex.EncodeToString(hash[:])
|
||||
if signature == hexStr {
|
||||
c.String(http.StatusOK, echoStr)
|
||||
} else {
|
||||
c.Status(http.StatusForbidden)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user