更新
This commit is contained in:
1 parent
5718a00e31
commit
1850ac640e
226 files changed
+37772
-12071
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"server/models"
|
||||
"server/pkg/identity"
|
||||
"server/pkg/jwtutil"
|
||||
"server/services"
|
||||
authsvc "server/services/auth"
|
||||
@@ -21,20 +22,10 @@ type PlatformTenantApplyController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// platformClaims 入驻申请的审核接口只在平台端使用:必须是 platform 端令牌。
|
||||
// 此前不判端,租户自己的令牌就能批准自己入驻,等于把审核权下发到了被审核方。
|
||||
func (c *PlatformTenantApplyController) platformClaims() (*jwtutil.Claims, error) {
|
||||
auth := c.Ctx.Request.Header.Get("Authorization")
|
||||
if auth == "" {
|
||||
return nil, fmt.Errorf("未登录")
|
||||
}
|
||||
parts := strings.SplitN(auth, " ", 2)
|
||||
if len(parts) != 2 || parts[0] != "Bearer" {
|
||||
return nil, fmt.Errorf("token 格式错误")
|
||||
}
|
||||
claims, err := jwtutil.ParseToken(parts[1])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("token 无效")
|
||||
}
|
||||
return claims, nil
|
||||
return identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndPlatform)
|
||||
}
|
||||
|
||||
func (c *PlatformTenantApplyController) jsonErr(httpStatus, bizCode int, msg string) {
|
||||
@@ -75,7 +66,8 @@ func (c *PlatformTenantApplyController) reviewerName(claims *jwtutil.Claims) str
|
||||
func (c *PlatformTenantApplyController) List() {
|
||||
claims, err := c.platformClaims()
|
||||
if err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
_ = claims
|
||||
@@ -117,12 +109,12 @@ func (c *PlatformTenantApplyController) List() {
|
||||
list := make([]applyDTO, 0, len(rows))
|
||||
for _, r := range rows {
|
||||
dto := applyDTO{AuthTenantApply: r}
|
||||
if identity, ierr := authsvc.GetIdentityByID(r.IdentityID); ierr == nil && identity != nil {
|
||||
if identity.Nickname != nil {
|
||||
dto.IdentityNickname = *identity.Nickname
|
||||
if ident, ierr := authsvc.GetIdentityByID(r.IdentityID); ierr == nil && ident != nil {
|
||||
if ident.Nickname != nil {
|
||||
dto.IdentityNickname = *ident.Nickname
|
||||
}
|
||||
if identity.Mobile != nil {
|
||||
dto.IdentityMobile = *identity.Mobile
|
||||
if ident.Mobile != nil {
|
||||
dto.IdentityMobile = *ident.Mobile
|
||||
}
|
||||
}
|
||||
list = append(list, dto)
|
||||
@@ -140,7 +132,8 @@ func (c *PlatformTenantApplyController) List() {
|
||||
func (c *PlatformTenantApplyController) Detail() {
|
||||
claims, err := c.platformClaims()
|
||||
if err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
_ = claims
|
||||
@@ -166,7 +159,8 @@ func (c *PlatformTenantApplyController) Detail() {
|
||||
func (c *PlatformTenantApplyController) Approve() {
|
||||
claims, err := c.platformClaims()
|
||||
if err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
id, err := strconv.ParseUint(c.Ctx.Input.Param(":id"), 10, 64)
|
||||
@@ -191,7 +185,8 @@ func (c *PlatformTenantApplyController) Approve() {
|
||||
func (c *PlatformTenantApplyController) Reject() {
|
||||
claims, err := c.platformClaims()
|
||||
if err != nil {
|
||||
c.jsonErr(401, 401, err.Error())
|
||||
code := identity.Status(err)
|
||||
c.jsonErr(code, code, err.Error())
|
||||
return
|
||||
}
|
||||
_ = claims
|
||||
|
||||
Reference in new issue
Block a user