本文整理匯總了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")
}