mantis的登陆

OpenTest, PHP&MYSQL, Solution Add comments |

mantis 提供多种登陆方式:

# login methods
define( ‘PLAIN’, 0 );
define( ‘CRYPT’, 1 );
define( ‘CRYPT_FULL_SALT’, 2 );
define( ‘MD5′, 3 );
define( ‘LDAP’, 4 );
define( ‘BASIC_AUTH’, 5 );
define( ‘HTTP_AUTH’, 6 );

这些功能提供得还是非常好的。可能需要配置下,不过第一阶段的工作围绕在mysql中做auth所以其它暂时不做多考虑。bugs_form_login_post.jpg

在login.php中对post的数据实行:

auth_attempt_login( $f_username, $f_password, $f_perm_login )

$f_*由gpc_get_string(bool…其它类型)[貌视很不错的方式,严谨]获得

在core/authentication_api.php 中line:69中显示了auth_attempt_login( $p_username, $p_password, $p_perm_login=false )函数; 进行了几步验证。

  1. $t_user_id = user_get_id_by_name( $p_username );通过用户名获得uid
  2. 获取登陆方法$t_login_method = config_get( ‘login_method’ );
  3. 如果从mysql 得不到user_id判断是否是由base_auth方式登陆
  4. # 账户是否停用
    if ( !user_is_enabled( $t_user_id ) ) {
    return false;
    }
  5. //检查错误登陆次数超标与否
    if( !user_is_login_request_allowed( $t_user_id ) ) {
    return false;
    }
  6. 进行判断匿名用户登陆验证
  7. 终于可以登陆了。
  8. # increment login count增加登陆次数
    user_increment_login_count( $t_user_id );
    //将登陆错误次数清零
    user_reset_failed_login_count_to_zero( $t_user_id );
    //忘记密码次数清零
    user_reset_lost_password_in_progress_count_to_zero( $t_user_id );# set the cookies
    auth_set_cookies( $t_user_id, $p_perm_login );
    auth_set_tokens( $t_user_id );

函数完毕;

如果perm_login是true的话

# set permanent cookie (1 year);

打完收工。

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.81 秒 苏ICP备07500719号

Entries RSS Comments RSS 登录
Links to Page