From 601b8a5888ae7e83b832fd2d867ea9f9e65ebadf Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 13 Jun 2024 13:20:43 +0800 Subject: [PATCH] by Robin at 20240613 --- app/mix/service/apiservice.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 44639a43..fce03e88 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -80,12 +80,14 @@ func (s *Service) ApiLoginByPswd(ctx *gin.Context, req *loginproto.ApiLoginByPsw } // 2.让已登录的用户强制下线 - if util.DerefInt64(login.IsLogined) == 1 { - if _, ec = s.ApiLogout(ctx, &loginproto.ApiLogoutReq{ - Mid: account.Mid, - }); ec != errcode.ErrCodeLoginSrvOk { - logger.Error("ApiLogout failed!") - return + if account.GetRole() == consts.User { + if util.DerefInt64(login.IsLogined) == 1 { + if _, ec = s.ApiLogout(ctx, &loginproto.ApiLogoutReq{ + Mid: account.Mid, + }); ec != errcode.ErrCodeLoginSrvOk { + logger.Error("ApiLogout failed!") + return + } } } @@ -155,12 +157,14 @@ func (s *Service) ApiLoginByVeriCode(ctx *gin.Context, req *loginproto.ApiLoginB } // 4.让已登录的用户强制下线 - if util.DerefInt64(login.IsLogined) == 1 { - if _, ec = s.ApiLogout(ctx, &loginproto.ApiLogoutReq{ - Mid: account.Mid, - }); ec != errcode.ErrCodeLoginSrvOk { - logger.Error("ApiLogout failed!") - return + if account.GetRole() == consts.User { + if util.DerefInt64(login.IsLogined) == 1 { + if _, ec = s.ApiLogout(ctx, &loginproto.ApiLogoutReq{ + Mid: account.Mid, + }); ec != errcode.ErrCodeLoginSrvOk { + logger.Error("ApiLogout failed!") + return + } } }