fix: check if the token is shared before removing
This commit is contained in:
@@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"message-pusher/channel"
|
||||
"message-pusher/common"
|
||||
"strings"
|
||||
)
|
||||
@@ -168,6 +169,16 @@ 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