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