本文整理汇总了Golang中github.com/couchbaselabs/sync_gateway/auth.User.UnauthError方法的典型用法代码示例。如果您正苦于以下问题:Golang User.UnauthError方法的具体用法?Golang User.UnauthError怎么用?Golang User.UnauthError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbaselabs/sync_gateway/auth.User
的用法示例。
在下文中一共展示了User.UnauthError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
}
示例2: 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
} else if user.Channels != nil {
for _, channel := range user.Channels {
if channel == "*" {
return nil
}
value, exists := channels[channel]
if exists && value == nil {
return nil // yup, it's in this channel
}
}
}
return user.UnauthError("You are not allowed to see this")
}