新增访客模式

This commit is contained in:
Liujian
2024-08-16 11:27:41 +08:00
parent 9525b0622b
commit 400687914a
4 changed files with 18 additions and 20 deletions
+2 -7
View File
@@ -5,9 +5,9 @@ go 1.21
//toolchain go1.21.1
require (
github.com/eolinker/ap-account v1.0.7
github.com/eolinker/ap-account v1.0.8
github.com/eolinker/eosc v0.17.3
github.com/eolinker/go-common v1.0.1
github.com/eolinker/go-common v1.0.2
github.com/gabriel-vasile/mimetype v1.4.4
github.com/gin-gonic/gin v1.10.0
github.com/google/uuid v1.6.0
@@ -65,8 +65,3 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/mysql v1.5.2 // indirect
)
//replace (
// github.com/eolinker/ap-account => ../../eolinker/ap-account
// github.com/eolinker/go-common => ../../eolinker/go-common
//)
+4 -4
View File
@@ -23,12 +23,12 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eolinker/ap-account v1.0.7 h1:gmltZ0v/0SFY4LElhLWRDQfNpr3Q74A9/T8m+upYiVM=
github.com/eolinker/ap-account v1.0.7/go.mod h1:MViCOvUaS2QrVift1Be3yGjjMywzICL9317eOxoixSI=
github.com/eolinker/ap-account v1.0.8 h1:HDU7WdxWu7HU8zBJc8z2itbfh89KrFfXwJHP/WtGG3Q=
github.com/eolinker/ap-account v1.0.8/go.mod h1:5lsZwkQfnHO5YJ3Cu6X1PZwZ0gbmJBUcix0hxG8aEsY=
github.com/eolinker/eosc v0.17.3 h1:sr2yT+v/AsqEdciRaaZZj0zL9pTufR5RvDW6+65hraQ=
github.com/eolinker/eosc v0.17.3/go.mod h1:xgq816hpanlMXFtZw7Ztdctb1eEk9UPHchY4NfFO6Cw=
github.com/eolinker/go-common v1.0.1 h1:Uan6QmXAlPiX6hc1ptSIHWvaWXNA+VlBjC4gCaDEiz0=
github.com/eolinker/go-common v1.0.1/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
github.com/eolinker/go-common v1.0.2 h1:rGxcrDdHr+mtMHVPdz3tx7oOsKLo0Msy6W0U1ZNsXaQ=
github.com/eolinker/go-common v1.0.2/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
+6 -4
View File
@@ -2,7 +2,7 @@ package system
import (
"context"
"errors"
"github.com/eolinker/go-common/access"
"reflect"
"github.com/gin-gonic/gin"
@@ -25,10 +25,12 @@ type imlSystemPermitModule struct {
}
func (m *imlSystemPermitModule) accesses(ctx context.Context) ([]string, error) {
uid := utils.UserId(ctx)
if uid == "" {
return nil, errors.New("not login")
// 判断是否是访客,如果是,直接返回访客权限
if utils.GuestAllow() && utils.IsGuest(ctx) {
return access.GuestAccess(role.SystemTarget()), nil
}
uid := utils.UserId(ctx)
roleMembers, err := m.roleMemberService.List(ctx, role.SystemTarget(), uid)
if err != nil {
return nil, err
+6 -5
View File
@@ -2,8 +2,7 @@ package team
import (
"context"
"errors"
"github.com/eolinker/go-common/access"
"github.com/eolinker/go-common/permit"
"github.com/gin-gonic/gin"
@@ -57,10 +56,12 @@ func (m *imlTeamPermitModule) OnComplete() {
}
func (m *imlTeamPermitModule) accesses(ctx context.Context, teamId string) ([]string, error) {
uid := utils.UserId(ctx)
if uid == "" {
return nil, errors.New("not login")
// 判断是否是访客,如果是,直接返回访客权限
if utils.GuestAllow() && utils.IsGuest(ctx) {
return access.GuestAccess(role.SystemTarget()), nil
}
uid := utils.UserId(ctx)
roleMembers, err := m.roleMemberService.List(ctx, role.TeamTarget(teamId), uid)
if err != nil {
return nil, err