From 4ee2f3d3ee0a975720112a4e1dd321c321762bd2 Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 21 Feb 2022 16:20:09 +0800 Subject: [PATCH] #1494 update --- models/wechat_bind.go | 3 +-- routers/authentication/wechat.go | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/models/wechat_bind.go b/models/wechat_bind.go index b89a68cd9..f75188280 100644 --- a/models/wechat_bind.go +++ b/models/wechat_bind.go @@ -54,8 +54,7 @@ func UnbindWechatOpenId(userId int64, oldWechatOpenID string) error { return err } - param := &User{WechatOpenId: ""} - n, err := x.Where("ID = ? AND wechat_open_id =?", userId, oldWechatOpenID).Update(param) + n, err := x.Table(new(User)).Where("ID = ? AND wechat_open_id =?", userId, oldWechatOpenID).Update(map[string]interface{}{"wechat_open_id": ""}) if err != nil { log.Error("update wechat_open_id failed,e=%v", err) return err diff --git a/routers/authentication/wechat.go b/routers/authentication/wechat.go index 0139bb09f..4362b251e 100644 --- a/routers/authentication/wechat.go +++ b/routers/authentication/wechat.go @@ -67,7 +67,10 @@ func GetBindStatus(ctx *context.Context) { // UnbindWechat func UnbindWechat(ctx *context.Context) { - wechat.UnbindWechat(ctx.User.ID, ctx.User.WechatOpenId) + if ctx.User.WechatOpenId != "" { + wechat.UnbindWechat(ctx.User.ID, ctx.User.WechatOpenId) + } + ctx.JSON(200, map[string]interface{}{ "code": "00", "msg": "success",