是的,这很容易做到.你可以在这里选择:你可以注册一个proc来运行而不是所有的POST,或者你可以注册一个过滤器在POST之前运行并过滤掉某些用户或其他什么.我认为过滤器是更好的选择.
要执行此操作,请使用ns_register_proc或ns_register_filter(使用preauth)注册proc或过滤器.将以下代码放在OpenACS包的tcl文件夹下的.tcl文件中,或者放在主AOLserver/web/servername/tcl目录下.
过滤示例:
ns_register_filter preauth POST / filter_posts
proc filter_posts {} {
set user_id [ad_verify_and_get_user_id]
set list_of_allowed_user_ids [21 567 8999]
if {[lsearch -exact $list_of_allowed_user_ids $user_id] == -1 } {
#this user isn't allowed - so redirect them
ns_returnredirect "/register/"
# tell AOLserver to abort this thread
return filter_return
} else {
# this user is allowed, tell AOLserver to continue
return filter_ok
}
}
Run Code Online (Sandbox Code Playgroud)
Proc例子:
ns_register_proc POST / handle_posts
proc handle_posts {} {
ns_returnredirect "http://someotherwebsite.com"
}
Run Code Online (Sandbox Code Playgroud)