thread-master/apps/backend/internal/logic/radar/owner.go

23 lines
526 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package radar
import (
"context"
"apps/backend/internal/middleware"
"apps/backend/internal/response"
)
/*
ownerUID 取登入 uid是 radar 全部資源的隔離依據。
request 若帶了 uid 一律忽略:整個 group 只讀寫自己的資料spec §5.1、§7
少了這道就等於開放任意越權讀寫。
*/
func ownerUID(ctx context.Context) (int64, error) {
uid, ok := middleware.UIDFrom(ctx)
if !ok || uid <= 0 {
return 0, response.Biz(401, 401001, "missing authorization")
}
return uid, nil
}