ci dx_auth认证

最近看到了一个比较好的ci认证类,特此分享

 

 

下面是 DX Auth 库中的配置,你可以看一下代码中的注释。

/*
| -------------------------------------------------------------------
| DX Auth Config
| -------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| 网站细节
|--------------------------------------------------------------------------
|
| 这些细节用于 DX Auth 库发送的E-mail里。
|
*/
$config['DX_website_name'] = '你的网站名';
$config['DX_webmaster_email'] =
'webmaster@yourhost.com' ;
/*
|--------------------------------------------------------------------------
| 数据库表
|--------------------------------------------------------------------------
|
| 设定 DX Auth 使用的表
|
| 'DX_table_prefix' 允许你指定其余表用到的表前缀
|
| 例如 'DX_table_prefix' 设定为 'DX_','DX_users_table' 设置为 'user',
| 将会使 DX Auth 使用 'DX_users' 作为用户表.
|
*/
$config['DX_table_prefix'] = '';
$config['DX_users_table'] = 'users';
$config['DX_user_profile_table'] = 'user_profile';
$config['DX_user_temp_table'] = 'user_temp';
$config['DX_user_autologin'] = 'user_autologin';
$config['DX_roles_table'] = 'roles';
$config['DX_permissions_table'] = 'permissions';
$config['DX_login_attempts_table'] = 'login_attempts';
/*
|--------------------------------------------------------------------------
| 密码混淆 (salt)
|--------------------------------------------------------------------------
|
| You can add major salt to be hashed with password.
| For example, you can get salt from here:
https://www.grc.com/passwords.htm
|
| 注意:
|
| 记住如果你在有用户注册之后修改此值,之前注册的用户将无法再登录
|
*/
$config['DX_salt'] = '';
/*
|--------------------------------------------------------------------------
| 注册相关设置
|--------------------------------------------------------------------------
|
| 'DX_email_activation' = 要求用户注册后激活他们的帐号
| 'DX_email_activation_expire' = 激活限制时间,超过此时间扔未激活的用户将被从数据库中删除。默认是48小时 (60*60*24*2)。
| 'DX_email_account_details' = 注册后发送帐号详情的邮件。只在 'DX_email_activation' 为 FALSE 时有效。
|
*/

$config['DX_email_activation'] = TRUE;
$config['DX_email_activation_expire'] = 60*60*24*2;
$config['DX_email_account_details'] = TRUE;
/*
|--------------------------------------------------------------------------
| 登录设置
|--------------------------------------------------------------------------
|
| 'DX_login_using_username' = 设定用户是否可以在用户名表单域使用用户名登录。
| 'DX_login_using_email' = 设定用户是否可以在用户名表单域使用E-mail登录。
|
| 以上两项你必须至少设置一项为True。
|
| 'DX_login_record_ip' = 设定当用户登录时是否将其IP保存到数据库。
| 'DX_login_record_time' = 设定当用户登录时是否记录其登录时间。
|
*/
$config['DX_login_using_username'] = TRUE;
$config['DX_login_using_email'] = TRUE;
$config['DX_login_record_ip'] = TRUE;
$config['DX_login_record_time'] = TRUE;
/*
|--------------------------------------------------------------------------
| 自动登录设置
|--------------------------------------------------------------------------
|
| 'DX_autologin_cookie_name' = 设置自动登录所使用的Cookie名字。
| 'DX_autologin_cookie_life' = 设置自动登录所使用的cookie有效时间。默认为2个月(60*60*24*31*2)。
|
*/
$config['DX_autologin_cookie_name'] = 'autologin';
$config['DX_autologin_cookie_life'] = 60*60*24*31*2;
/*
|--------------------------------------------------------------------------
| 登录尝试
|--------------------------------------------------------------------------
|
| 'DX_count_login_attempts' = 设定当用户登录失败是 DX Auth 是否统计登录失败次数。
| 'DX_max_login_attempts' = 设定函数 is_login_attempt_exceeded() 返回 TRUE 之前的最大尝试次数。
|
*/
$config['DX_count_login_attempts'] = TRUE;
$config['DX_max_login_attempts'] = 1;
/*
|--------------------------------------------------------------------------
| 忘记密码相关设置
|--------------------------------------------------------------------------
|
| 'DX_forgot_password_expire' = 忘记密码密钥超时时间,默认为 15 分钟(900 seconds)。
|
*/
$config['DX_forgot_password_expire'] = 900;
/*
|--------------------------------------------------------------------------
| 验证码
|--------------------------------------------------------------------------
|
| 你可以在此设定由 DX Auth 库生成的验证码。
| 'DX_captcha_directory' = 创建验证码的目录名称。
| 'DX_captcha_fonts_path' = 此目录中的字体将被用于验证码的创建。
| 'DX_captcha_font_size' = 文本写入验证码图片时的字体大小。使用随机大小请留空。
| 'DX_captcha_grid' = 在验证码图片中显示网格
| 'DX_captcha_expire' = 验证码超时时间,默认为3分钟(180 seconds)。
| 'DX_captcha_case_sensitive' = 设定验证码是否区分大小写。
|
*/
$config['DX_captcha_directory'] = 'captcha';
$config['DX_captcha_fonts_path'] = $config['DX_captcha_path'].'fonts';
$config['DX_captcha_width'] = 320;
$config['DX_captcha_height'] = 95;
$config['DX_captcha_font_size'] = '';
$config['DX_captcha_grid'] = TRUE;
$config['DX_captcha_expire'] = 180;
$config['DX_captcha_case_sensitive'] = TRUE;
/*
|--------------------------------------------------------------------------
| reCAPTCHA //此段略
|--------------------------------------------------------------------------
|
| If you are planning to use reCAPTCHA function, you have to set reCAPTCHA key here
| You can get the key by registering at
http://recaptcha.net
|
*/
$config['DX_recaptcha_public_key'] = '';
$config['DX_recaptcha_private_key'] = '';

/*
|--------------------------------------------------------------------------
| URI
|--------------------------------------------------------------------------
|
| 设定在 DX Auth 库中用于重定向的 URI
| 'DX_deny_uri' = 禁止访问 URI.
| 'DX_login_uri' = 登录表单 URI.
| 'DX_activate_uri' = 激活用户 URI.
| 'DX_reset_password_uri' = 重置密码 URI.
|
| 去掉'DX_'前缀,这些值可以由 DX Auth 库读取。
| 例如你可以在控制器中通过使用 $this->dx_auth->deny_uri 访问 'DX_deny_uri'。
|
*/
$config['DX_deny_uri'] = '/auth/deny/';
$config['DX_login_uri'] = '/auth/login/';
$config['DX_banned_uri'] = '/auth/banned/';
$config['DX_activate_uri'] = '/auth/activate/';
$config['DX_reset_password_uri'] = '/auth/reset_password/';

/*
|--------------------------------------------------------------------------
| 辅助函数配置
|--------------------------------------------------------------------------
|
| 下面的配置实际上在 DX_Auth 库中并没有用到。
| 它们只是帮助你在控制器里更容易地编写代码。
| 如果你不需要它你可以留空,或干脆删掉它。
|
| 然而它们可以通过去掉'DX_'前缀在 DX Auth 库中访问。
| 例如你可以在控制器中通过使用 $this->dx_auth->register_uri 访问 'DX_register_uri'。
|
*/
// 注册
$config['DX_allow_registration'] = TRUE;
$config['DX_captcha_registration'] = TRUE;
// 登录
$config['DX_captcha_login'] = FALSE;
// URI 路径
$config['DX_logout_uri'] = '/auth/logout/';
$config['DX_register_uri'] = '/auth/register/';
$config['DX_forgot_password_uri'] = '/auth/forgot_password/';
$config['DX_change_password_uri'] = '/auth/change_password/';
$config['DX_cancel_account_uri'] = '/auth/cancel_account/';
// 表单视图
$config['DX_login_view'] = 'auth/login_form';
$config['DX_register_view'] = 'auth/register_form';
$config['DX_forgot_password_view'] = 'auth/forgot_password_form';
$config['DX_change_password_view'] = 'auth/change_password_form';
$config['DX_cancel_account_view'] = 'auth/cancel_account_form';
// 页面视图
$config['DX_deny_view'] = 'auth/general_message';
$config['DX_banned_view'] = 'auth/general_message';
$config['DX_logged_in_view'] = 'auth/general_message';
$config['DX_logout_view'] = 'auth/general_message';
$config['DX_register_success_view'] = 'auth/general_message';
$config['DX_activate_success_view'] = 'auth/general_message';
$config['DX_forgot_password_success_view'] = 'auth/general_message';
$config['DX_reset_password_success_view'] = 'auth/general_message';
$config['DX_change_password_success_view'] = 'auth/general_message';

$config['DX_register_disabled_view'] = 'auth/general_message';
$config['DX_activate_failed_view'] = 'auth/general_message';
$config['DX_reset_password_failed_view'] = 'auth/general_message';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值