24 lines
601 B
Go
24 lines
601 B
Go
|
|
package job
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"haixun-backend/internal/library/authctx"
|
||
|
|
app "haixun-backend/internal/library/errors"
|
||
|
|
"haixun-backend/internal/library/errors/code"
|
||
|
|
"haixun-backend/internal/logic/authz"
|
||
|
|
"haixun-backend/internal/svc"
|
||
|
|
)
|
||
|
|
|
||
|
|
func actorFrom(ctx context.Context) (tenantID, uid string, err error) {
|
||
|
|
actor, ok := authctx.ActorFromContext(ctx)
|
||
|
|
if !ok {
|
||
|
|
return "", "", app.For(code.Auth).AuthUnauthorized("missing actor")
|
||
|
|
}
|
||
|
|
return actor.TenantID, actor.UID, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func requireAdmin(ctx context.Context, svcCtx *svc.ServiceContext) error {
|
||
|
|
return authz.RequireAdmin(ctx, svcCtx)
|
||
|
|
}
|