discuz X3用户登录uc_user_login()函数详解

简介:

discuz X3用户登录uc_user_login()函数详解


验证用户登录 discuz x3/source/function/function_member.php中大约35行左右:

1
2
3
4
5
6
7
8
9
10
11
12
13
if ( $isuid  == 3) {
     if (! strcmp (dintval( $username ),  $username ) && getglobal( 'setting/uidlogin' )) {
         $return [ 'ucresult' ] = uc_user_login( $username $password , 1, 1,  $questionid $answer $ip );
     elseif (isemail( $username )) {
         $return [ 'ucresult' ] = uc_user_login( $username $password , 2, 1,  $questionid $answer $ip );
     }
     if ( $return [ 'ucresult' ][0] <= 0 &&  $return [ 'ucresult' ][0] != -3) {
         $return [ 'ucresult' ] = uc_user_login( addslashes ( $username ),  $password , 0, 1,  $questionid $answer $ip );
     }
}
else  {
     $return [ 'ucresult' ] = uc_user_login( addslashes ( $username ),  $password $isuid , 1,  $questionid $answer $ip );
}


这里的uc_user_login()就是去验证登录是否成功:

用户登录:

array uc_user_login(

string username ,

string password,

bool isuid ,

bool checkques ,

integer questionid ,

string answer

)

函数参数
参数 含义
string username 用户名 / 用户 ID
string password 密码
bool isuid 是否使用用户 ID登录
1:使用用户 ID登录
0:(默认值) 使用用户名登录
bool checkques 是否验证安装提问
1:验证安全提问
0:(默认值) 不验证安全提问
integer questionid 安全提问索引
string answer 安全提问答案
返回值
含义
array integer [0] 大于 0:返回用户 ID,表示用户登录成功
-1:用户不存在,或者被删除
-2:密码错
-3:安全提问错
string [1] 用户名
string [2] 密码
string [3] Email
bool [4] 用户名是否重名

本接口函数用于用户的登录验证,用户名及密码正确无误则返回用户在 UCenter 的基本数据,否则返回相应的错误信息。如果应用程序是升级过来的,并且当前登录用户和已有用户重名,那么返回的数组中 [4] 的值将返回 1。



附加获取用户数据方法:uc_get_user()

获取用户数据:

array uc_get_user(

string username,

bool isuid

)

函数参数
参数 含义
string username 用户名
bool isuid 是否使用用户 ID获取
1:使用用户 ID获取
0:(默认值) 使用用户名获取
返回值
含义
array integer [0] 用户 ID
string [1] 用户名
string [2] Email

本接口函数用于获取用户在 UCenter 的基本数据,如用户不存在,返回值为 integer 的数值 0。






      本文转自许琴 51CTO博客,原文链接:http://blog.51cto.com/xuqin/1293562,如需转载请自行联系原作者





相关文章
|
9月前
【亲测】cgi-bin/user/info获取用户信息接口部分用户unionId获取不到?
【亲测】cgi-bin/user/info获取用户信息接口部分用户unionId获取不到?
232 0
|
10月前
|
缓存 小程序 前端开发
【微信小程序】wx.login实现用户登录
【微信小程序】wx.login实现用户登录
|
关系型数据库 MySQL Linux
Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误
Linux登录mysql忘记密码Access denied for user ‘root‘@‘localhost‘ (using password: YES)错误
251 0
|
11月前
|
安全 Linux 网络安全
手机登录服务器用root和administrator做登录名,都提示别名已存在
【2月更文挑战第5天】手机登录服务器用root和administrator做登录名,都提示别名已存在
94 8
|
11月前
|
SQL PHP 数据库
PHP案例:每一个账号登陆后的操作是隔离的(使用token进行登录)
PHP案例:每一个账号登陆后的操作是隔离的(使用token进行登录)
PHP案例:每一个账号登陆后的操作是隔离的(使用token进行登录)
|
关系型数据库 MySQL 数据库连接
mac 环境下 登陆失败问题Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)
mac 环境下 登陆失败问题Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)
201 0
|
PHP
【laravel】在使用Auth认证时,登录后直接进入home,不登录会直接跳转到login
【laravel】在使用Auth认证时,登录后直接进入home,不登录会直接跳转到login
377 0
【laravel】在使用Auth认证时,登录后直接进入home,不登录会直接跳转到login
|
小程序
【微信小程序错误】Error:用户未登录过,请先使用login()登录
这个错误需要将登录程序时写的loginWithCode方法换成login方法
603 0
|
小程序
WeChat小程序的登录授权关于token
WeChat小程序的登录授权关于token
根据user_id实现支付宝账号登录
如图所示简单的实现支付宝登录 第一步:授权链接获得auth_code 第二步:通过接口获取user_id,其他信息由用户主动填写。不走获取用户信息接口直接实现。 用户信息授权和app登录都使用alipay.system.oauth.token接口获取user_id. 
1008 12