fix: fix circular import
This commit is contained in:
@@ -110,7 +110,7 @@ func TokenStoreUpdateUser(cleanUser *model.User, originUser *model.User) {
|
|||||||
if cleanUser.WeChatTestAccountSecret != "" {
|
if cleanUser.WeChatTestAccountSecret != "" {
|
||||||
newWeChatTestAccountTokenStoreItem.AppSecret = cleanUser.WeChatTestAccountSecret
|
newWeChatTestAccountTokenStoreItem.AppSecret = cleanUser.WeChatTestAccountSecret
|
||||||
}
|
}
|
||||||
if !model.IsWeChatTestAccountTokenShared(&oldWeChatTestAccountTokenStoreItem) {
|
if !oldWeChatTestAccountTokenStoreItem.IsShared() {
|
||||||
TokenStoreRemoveItem(&oldWeChatTestAccountTokenStoreItem)
|
TokenStoreRemoveItem(&oldWeChatTestAccountTokenStoreItem)
|
||||||
}
|
}
|
||||||
TokenStoreAddItem(&newWeChatTestAccountTokenStoreItem)
|
TokenStoreAddItem(&newWeChatTestAccountTokenStoreItem)
|
||||||
@@ -140,7 +140,7 @@ func TokenStoreUpdateUser(cleanUser *model.User, originUser *model.User) {
|
|||||||
if cleanUser.WeChatCorpAccountAgentId != "" {
|
if cleanUser.WeChatCorpAccountAgentId != "" {
|
||||||
newWeChatCorpAccountTokenStoreItem.AgentId = cleanUser.WeChatCorpAccountAgentId
|
newWeChatCorpAccountTokenStoreItem.AgentId = cleanUser.WeChatCorpAccountAgentId
|
||||||
}
|
}
|
||||||
if !model.IsWeChatCorpAccountTokenShared(&oldWeChatCorpAccountTokenStoreItem) {
|
if !oldWeChatCorpAccountTokenStoreItem.IsShared() {
|
||||||
TokenStoreRemoveItem(&oldWeChatCorpAccountTokenStoreItem)
|
TokenStoreRemoveItem(&oldWeChatCorpAccountTokenStoreItem)
|
||||||
}
|
}
|
||||||
TokenStoreAddItem(&newWeChatCorpAccountTokenStoreItem)
|
TokenStoreAddItem(&newWeChatCorpAccountTokenStoreItem)
|
||||||
@@ -153,7 +153,7 @@ func TokenStoreRemoveUser(user *model.User) {
|
|||||||
AppID: user.WeChatTestAccountId,
|
AppID: user.WeChatTestAccountId,
|
||||||
AppSecret: user.WeChatTestAccountSecret,
|
AppSecret: user.WeChatTestAccountSecret,
|
||||||
}
|
}
|
||||||
if !model.IsWeChatTestAccountTokenShared(&testAccountTokenStoreItem) {
|
if !testAccountTokenStoreItem.IsShared() {
|
||||||
TokenStoreRemoveItem(&testAccountTokenStoreItem)
|
TokenStoreRemoveItem(&testAccountTokenStoreItem)
|
||||||
}
|
}
|
||||||
corpAccountTokenStoreItem := WeChatCorpAccountTokenStoreItem{
|
corpAccountTokenStoreItem := WeChatCorpAccountTokenStoreItem{
|
||||||
@@ -161,7 +161,7 @@ func TokenStoreRemoveUser(user *model.User) {
|
|||||||
CorpSecret: user.WeChatCorpAccountSecret,
|
CorpSecret: user.WeChatCorpAccountSecret,
|
||||||
AgentId: user.WeChatCorpAccountAgentId,
|
AgentId: user.WeChatCorpAccountAgentId,
|
||||||
}
|
}
|
||||||
if !model.IsWeChatCorpAccountTokenShared(&corpAccountTokenStoreItem) {
|
if !corpAccountTokenStoreItem.IsShared() {
|
||||||
TokenStoreRemoveItem(&corpAccountTokenStoreItem)
|
TokenStoreRemoveItem(&corpAccountTokenStoreItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ func (i *WeChatCorpAccountTokenStoreItem) Key() string {
|
|||||||
return i.CorpId + i.AgentId + i.CorpSecret
|
return i.CorpId + i.AgentId + i.CorpSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *WeChatCorpAccountTokenStoreItem) IsShared() bool {
|
||||||
|
return model.DB.Where("wechat_corp_account_id = ? and wechat_corp_account_secret = ? and wechat_corp_account_agent_id = ?",
|
||||||
|
i.CorpId, i.CorpSecret, i.AgentId).Find(&model.User{}).RowsAffected != 1
|
||||||
|
}
|
||||||
|
|
||||||
func (i *WeChatCorpAccountTokenStoreItem) Token() string {
|
func (i *WeChatCorpAccountTokenStoreItem) Token() string {
|
||||||
return i.AccessToken
|
return i.AccessToken
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ func (i *WeChatTestAccountTokenStoreItem) Key() string {
|
|||||||
return i.AppID + i.AppSecret
|
return i.AppID + i.AppSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *WeChatTestAccountTokenStoreItem) IsShared() bool {
|
||||||
|
return model.DB.Where("wechat_test_account_id = ? and wechat_test_account_secret = ?",
|
||||||
|
i.AppID, i.AppSecret).Find(&model.User{}).RowsAffected != 1
|
||||||
|
}
|
||||||
|
|
||||||
func (i *WeChatTestAccountTokenStoreItem) Token() string {
|
func (i *WeChatTestAccountTokenStoreItem) Token() string {
|
||||||
return i.AccessToken
|
return i.AccessToken
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"message-pusher/channel"
|
|
||||||
"message-pusher/common"
|
"message-pusher/common"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -169,16 +168,6 @@ func IsUsernameAlreadyTaken(username string) bool {
|
|||||||
return DB.Where("username = ?", username).Find(&User{}).RowsAffected == 1
|
return DB.Where("username = ?", username).Find(&User{}).RowsAffected == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsWeChatTestAccountTokenShared(item *channel.WeChatTestAccountTokenStoreItem) bool {
|
|
||||||
return DB.Where("wechat_test_account_id = ? and wechat_test_account_secret = ?",
|
|
||||||
item.AppID, item.AppSecret).Find(&User{}).RowsAffected != 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsWeChatCorpAccountTokenShared(item *channel.WeChatCorpAccountTokenStoreItem) bool {
|
|
||||||
return DB.Where("wechat_corp_account_id = ? and wechat_corp_account_secret = ? and wechat_corp_account_agent_id = ?",
|
|
||||||
item.CorpId, item.CorpSecret, item.AgentId).Find(&User{}).RowsAffected != 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResetUserPasswordByEmail(email string, password string) error {
|
func ResetUserPasswordByEmail(email string, password string) error {
|
||||||
hashedPassword, err := common.Password2Hash(password)
|
hashedPassword, err := common.Password2Hash(password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user