切换导航条
此项目
正在载入...
登录
郭盛
/
enterprise
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
何书鹏
4 years ago
提交
b6e18e8e2ee424f768fe0f0380c3bd598cf5d84e
2 个父辈
a67757a1
b7a25e2a
1 个管道 的构建
通过
耗费 4 秒
合并分支 'heshupeng' 到 'master'
app账号与pc端账号统一 查看合并请求
!168
变更
1
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
32 行增加
和
38 行删除
application/mobile/controller/User.php
application/mobile/controller/User.php
查看文件 @
b6e18e8
...
...
@@ -70,7 +70,7 @@ class User extends Api
Db
::
startTrans
();
try
{
$ret
=
$this
->
auth
->
register
(
$
username
=
get_order_sn
()
,
$password
,
$email
=
''
,
$mobile
,
[]);
$ret
=
$this
->
auth
->
register
(
$
mobile
,
$password
,
$email
=
''
,
$mobile
,
[]);
// 记录每日注册数量
$statistic
=
Statistic
::
where
(
'today'
,
date
(
'Y-m-d'
))
->
find
();
if
(
$statistic
){
...
...
@@ -81,6 +81,8 @@ class User extends Api
'today'
=>
date
(
'Y-m-d'
)
]);
}
// 密码设置为明文,与pc端统一
$this
->
auth
->
getUser
()
->
save
([
'password'
=>
$password
]);
Db
::
commit
();
}
catch
(
PDOException
$e
)
{
Db
::
rollback
();
...
...
@@ -156,7 +158,7 @@ class User extends Api
Db
::
startTrans
();
try
{
$ret
=
$this
->
auth
->
register
(
$
username
=
get_order_sn
()
,
$password
,
$email
=
''
,
$mobile
,
[]);
$ret
=
$this
->
auth
->
register
(
$
mobile
,
$password
,
$email
=
''
,
$mobile
,
[]);
$company
=
Company
::
create
([
'user_id'
=>
$this
->
auth
->
id
,
'name'
=>
$name
,
...
...
@@ -176,6 +178,8 @@ class User extends Api
'today'
=>
date
(
'Y-m-d'
)
]);
}
// 密码设置为明文,与pc端统一
$this
->
auth
->
getUser
()
->
save
([
'password'
=>
$password
]);
Db
::
commit
();
}
catch
(
PDOException
$e
)
{
Db
::
rollback
();
...
...
@@ -266,41 +270,27 @@ class User extends Api
$mobile
=
$this
->
request
->
param
(
'mobile'
);
$password
=
$this
->
request
->
param
(
'password'
);
empty
(
$mobile
)
&&
$this
->
error
(
'请输入手机号'
);
empty
(
$mobile
)
&&
$this
->
error
(
'请输入
账号或
手机号'
);
empty
(
$password
)
&&
$this
->
error
(
'请输入密码'
);
!
Validate
::
regex
(
$mobile
,
"^1\d
{
10
}
$"
)
&&
$this
->
error
(
'手机号格式不正确'
);
Db
::
startTrans
();
try
{
$ret
=
$this
->
auth
->
login
(
$mobile
,
$password
);
// 记录日活
$statistic
=
Statistic
::
where
(
'today'
,
date
(
'Y-m-d'
))
->
find
();
if
(
$statistic
){
$statistic
->
save
([
'active_times'
=>
$statistic
->
active_times
+
1
]);
}
else
{
(
new
Statistic
)
->
save
([
'active_times'
=>
1
,
'today'
=>
date
(
'Y-m-d'
)
]);
}
Db
::
commit
();
}
catch
(
PDOException
$e
)
{
Db
::
rollback
();
$this
->
auth
->
logout
();
$this
->
error
(
$e
->
getMessage
());
}
catch
(
Exception
$e
)
{
Db
::
rollback
();
$this
->
auth
->
logout
();
$this
->
error
(
$e
->
getMessage
());
}
if
(
$ret
)
{
$this
->
auth
->
setAllowFields
([
'id'
,
'mobile'
,
'group_id'
]);
$data
=
[
'userinfo'
=>
$this
->
auth
->
getUserInfo
()];
$this
->
success
(
'登录成功'
,
$data
);
}
else
{
Db
::
rollback
();
$this
->
error
(
$this
->
auth
->
getError
());
$field
=
Validate
::
regex
(
$mobile
,
'/^1\d{10}$/'
)
?
'mobile'
:
'username'
;
$user
=
\app\common\model\User
::
get
([
$field
=>
$mobile
]);
!
$user
&&
$this
->
error
(
__
(
'Account is incorrect'
));
$user
->
password
!=
$password
&&
$this
->
error
(
__
(
'Password is incorrect'
));
//直接登录会员
$this
->
auth
->
direct
(
$user
->
id
);
// 记录日活
$statistic
=
Statistic
::
where
(
'today'
,
date
(
'Y-m-d'
))
->
find
();
if
(
$statistic
){
$statistic
->
save
([
'active_times'
=>
$statistic
->
active_times
+
1
]);
}
else
{
(
new
Statistic
)
->
save
([
'active_times'
=>
1
,
'today'
=>
date
(
'Y-m-d'
)
]);
}
$this
->
auth
->
setAllowFields
([
'id'
,
'mobile'
,
'group_id'
]);
$data
=
[
'userinfo'
=>
$this
->
auth
->
getUserInfo
()];
$this
->
success
(
'登录成功'
,
$data
);
}
/**
...
...
@@ -543,8 +533,6 @@ class User extends Api
if
(
$this
->
auth
->
password
)
{
$this
->
error
(
'已设置过密码'
);
}
$salt
=
Random
::
alnum
();
$password
=
$this
->
auth
->
getEncryptPassword
(
$password
,
$salt
);
$user_model
=
new
\app\common\model\User
();
$result
=
$user_model
->
update
([
'id'
=>
$this
->
auth
->
id
,
'password'
=>
$password
,
'salt'
=>
$salt
]);
if
(
!
$result
)
{
...
...
@@ -579,7 +567,9 @@ class User extends Api
Smslib
::
flush
(
$mobile
,
'resetpwd'
);
//模拟一次登录
$this
->
auth
->
direct
(
$user
->
id
);
$ret
=
$this
->
auth
->
changepwd
(
$newpassword
,
''
,
true
);
// $ret = $this->auth->changepwd($newpassword, '', true);
// 密码设置为明文,与pc端统一
$ret
=
$this
->
auth
->
getUser
()
->
save
([
'password'
=>
$newpassword
]);
if
(
$ret
)
{
$this
->
success
(
'重置密码成功'
);
}
else
{
...
...
@@ -688,6 +678,10 @@ class User extends Api
$sex
=
$this
->
request
->
param
(
'sex'
);
if
(
$username
||
$nickname
||
$image
||
in_array
(
$sex
,[
0
,
1
]))
{
if
(
$username
)
{
$exists
=
\app\common\model\User
::
where
(
'username'
,
$username
)
->
where
(
'id'
,
'<>'
,
$this
->
auth
->
id
)
->
find
();
if
(
$exists
)
{
$this
->
error
(
'用户名已存在'
);
}
$user
->
username
=
$username
;
}
if
(
$nickname
)
{
...
...
请
注册
或
登录
后发表评论