本文整理匯總了Golang中github.com/couchbaselabs/sync_gateway/auth.User.CanSeeChannel方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.CanSeeChannel方法的具體用法?Golang User.CanSeeChannel怎麽用?Golang User.CanSeeChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/couchbaselabs/sync_gateway/auth.User
的用法示例。
在下文中一共展示了User.CanSeeChannel方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AuthorizeAnyDocChannels
// Returns an HTTP 403 error if the User is not allowed to access any of the document's channels.
// A nil User means access control is disabled, so the function will return nil.
func AuthorizeAnyDocChannels(user auth.User, channels ChannelMap) error {
if user == nil {
return nil
}
for channel, removed := range channels {
if removed == nil && user.CanSeeChannel(channel) {
return nil
}
}
if user.CanSeeChannel("*") {
return nil // Doc is not in any channels, but user has all-access
}
return user.UnauthError("You are not allowed to see this")
}