Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
e7280538
Commit
e7280538
authored
Nov 27, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user add
parent
49f32d09
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
3 deletions
+84
-3
UserAuthInterceptor.php
common/behaviors/UserAuthInterceptor.php
+2
-0
Admin.php
common/models/Admin.php
+1
-0
Admin.php
common/modelsgii/Admin.php
+4
-3
UserController.php
wallet/controllers/UserController.php
+77
-0
No files found.
common/behaviors/UserAuthInterceptor.php
View file @
e7280538
...
...
@@ -34,6 +34,8 @@ class UserAuthInterceptor extends ActionFilter
goto
doEnd
;
}
return
true
;
$group
=
$user
[
"data"
]
->
group
;
$user_id
=
$user
[
"data"
]
->
uid
;
$platform_id
=
$user
[
"data"
]
->
platform_id
;
...
...
common/models/Admin.php
View file @
e7280538
...
...
@@ -22,6 +22,7 @@ use yii\web\IdentityInterface;
* @property string $update_time
* @property integer $status
* @property integer $platform_id
* @property integer $group
*/
class
Admin
extends
\common\modelsgii\Admin
implements
IdentityInterface
{
...
...
common/modelsgii/Admin.php
View file @
e7280538
...
...
@@ -19,6 +19,7 @@ use yii\helpers\HtmlPurifier;
* @property string $update_time
* @property integer $status
* @property integer $platform_id
* @property integer $group
*/
class
Admin
extends
\common\core\BaseActiveRecord
{
...
...
@@ -48,7 +49,7 @@ class Admin extends \common\core\BaseActiveRecord
[[
'username'
],
'string'
,
'max'
=>
32
],
[[
'password'
],
'string'
,
'min'
=>
6
,
'max'
=>
60
],
[[
'salt'
],
'string'
,
'max'
=>
32
],
[
'access_token'
,
'safe'
]
[
[
'access_token'
,
'group'
]
,
'safe'
]
];
}
...
...
@@ -68,8 +69,8 @@ class Admin extends \common\core\BaseActiveRecord
'last_login_ip'
=>
'Last Login Ip'
,
'update_time'
=>
'Update Time'
,
'status'
=>
'Status'
,
'platform_id'
=>
'
platform_i
d'
,
'group'
=>
'
g
roup'
'platform_id'
=>
'
PlatformI
d'
,
'group'
=>
'
G
roup'
];
}
}
wallet/controllers/UserController.php
View file @
e7280538
...
...
@@ -358,4 +358,80 @@ class UserController extends BaseController
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
public
function
actionAdd
()
{
if
(
!
Yii
::
$app
->
request
->
isPost
)
{
$this
->
msg
=
'请求方式错误'
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
$group
=
Yii
::
$app
->
request
->
getGroup
();
if
(
!
in_array
(
$group
,
[
'administrator'
,
'admin'
]))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'当前用户无权操作'
;
goto
doEnd
;
}
$platform_id
=
Yii
::
$app
->
request
->
getPlatformId
();
if
(
'administrator'
===
$group
)
{
$platform_id
=
Yii
::
$app
->
request
->
post
(
'platform_id'
,
1
);
}
$token
=
Yii
::
$app
->
request
->
headers
->
get
(
'Token'
);
$user_info
=
Admin
::
verfication
(
$token
);
if
(
0
!=
$user_info
[
'code'
])
{
$this
->
msg
=
$user_info
[
'data'
];
$this
->
code
=
-
1
;
goto
doEnd
;
}
$data
=
Yii
::
$app
->
request
->
post
();
$username
=
Yii
::
$app
->
request
->
post
(
'username'
,
null
);
$password
=
Yii
::
$app
->
request
->
post
(
'password'
,
null
);
if
(
empty
(
$username
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'用户名不能为空'
;
goto
doEnd
;
}
if
(
empty
(
$password
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'密码不能为空'
;
goto
doEnd
;
}
if
(
strlen
(
$data
[
'password'
])
<
6
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'密码不能小于6字符'
;
goto
doEnd
;
}
$user
=
Admin
::
findByUsername
(
$username
);
if
(
$user
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'用户名已存在'
;
goto
doEnd
;
}
$params
=
[
'username'
=>
$username
,
'reg_time'
=>
time
(),
'status'
=>
$data
[
'status'
]
??
0
,
'update_time'
=>
0
,
'last_login_time'
=>
0
,
'group'
=>
'general'
,
'platform_id'
=>
$platform_id
,
'reg_ip'
=>
ip2long
(
Yii
::
$app
->
request
->
getUserIP
()),
'last_login_ip'
=>
ip2long
(
'127.0.0.1'
),
];
$model
=
new
Admin
();
#var_dump($model->getAttributes());exit;
$model
->
setAttributes
(
$params
);
$model
->
generateAuthKey
();
$model
->
setPassword
(
$password
);
$model
->
save
();
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment