更正Mantis的想法

OpenTest, Solution Add comments |

Mantis有个很不错的想法,提供了一套不错的验证方式;

可以设置匿名anonymous访问;也可以使用默认登陆的方式进入。不过我不打算让系统以外的用户来查看系统,所以关闭这个anonymous方式。^_^

好言归正传我们要仔细看下用户表了。

bugs_db_user.jpg

当时很奇怪他为什么提供一个cookie_string参数。原本以为用来记录登陆的cookies后来发现注册时,系统竟然提供了一个string然后,在相关页面验证:

 //是否启用匿名用户查看提交。
if ( auth_is_user_authenticated() && !current_user_is_anonymous() ) {
print_header_redirect( config_get( ‘default_home_page’ ) );
}

current_user_is_anonymous()当然是考虑匿名的。不管。

 # ——————–
# Return true if there is a currently logged in and authenticated user,
#  false otherwise
function auth_is_user_authenticated() {
//dump(auth_get_current_user_cookie());show_vars();exit;
return ( auth_is_cookie_valid( auth_get_current_user_cookie() ) );
}

auth_is_cookie_valid($p_cookie_string)验证cookie中的MANTIS_STRING_COOKIE

是否在数据库中存在。

One Response to “更正Mantis的想法”

  1. chaodong sheng Says:

    注销实现:

    # ——————–
    # Logout the current user and remove any remaining cookies from their browser
    # Returns true on success, false otherwise
    function auth_logout() {
    global $g_cache_current_user_id;

    # clear cached userid
    $g_cache_current_user_id = null;

    # clear cookies, if they were set
    if (auth_clear_cookies()) {
    helper_clear_pref_cookies();
    }
    return true;
    }

Leave a Reply

You must be logged in to post a comment.


Powered byWordPress 2.6.2 | Theme by N.Design Studio | Processed in 0.83 秒 苏ICP备07500719号

Entries RSS Comments RSS 登录
Links to Page