Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
hujun
tl_estate
Commits
c971d5f3
Commit
c971d5f3
authored
Dec 08, 2017
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login
parent
15022c83
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
16 deletions
+50
-16
Member.php
application/api/controller/Member.php
+21
-16
JwtUntils.php
application/api/untils/JwtUntils.php
+29
-0
No files found.
application/api/controller/Member.php
View file @
c971d5f3
...
...
@@ -9,7 +9,7 @@ use app\api\untils\MessageUntils;
use
app\model\Users
;
use
app\model\NoteLog
;
use
think\Session
;
use
app\api\untils\JwtUntils
;
class
Member
extends
Basic
{
public
$user
;
...
...
@@ -21,24 +21,29 @@ class Member extends Basic
public
function
login
()
{
$post
=
$this
->
request
->
param
();
$user_data
=
$this
->
user
->
get
([
'user_phone'
=>
$this
->
params
[
'phone'
],
'status'
=>
0
,
]);
$user_data
=
$this
->
user
->
get
([
'user_phone'
=>
$post
[
'phone'
]]);
$data
[
'data'
]
=
''
;
if
(
empty
(
$user_data
->
id
))
{
$result
=
$this
->
user
->
validate
(
true
)
->
save
([
'user_phone'
=>
$post
[
'phone'
],
'referrer_id'
=>
$post
[
'referrer_id'
],
]);
if
(
false
===
$result
)
{
$data
[
'status'
]
=
101
;
$data
[
'msg'
]
=
$this
->
user
->
getError
();
$data
[
'data'
]
=
''
;
$data
[
'status'
]
=
101
;
if
(
isset
(
$user_data
->
id
))
{
if
(
$user_data
->
user_pswd
==
md5
(
md5
(
$this
->
params
[
'pwd'
])
.
'+123'
))
{
$jwt_data
[
'id'
]
=
$user_data
->
id
;
$jwt_data
[
'user_nick'
]
=
$user_data
->
user_nick
;
$jwt_data
[
'user_phone'
]
=
$user_data
->
user_phone
;
$jwt
=
new
JwtUntils
();
$data
[
'data'
]
=
$user_data
->
getData
();
$data
[
'data'
][
'authToken'
]
=
$jwt
->
createToken
(
$jwt_data
);
$data
[
'msg'
]
=
'登陆成功'
;
$data
[
'status'
]
=
200
;
}
else
{
$data
[
'msg'
]
=
'密码错误'
;
}
}
else
{
$data
[
'msg'
]
=
'已注册'
;
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
'没有该用户'
;
}
return
$this
->
response
(
$data
[
'status'
],
$data
[
'msg'
],
$data
[
'data'
]);
...
...
application/api/untils/JwtUntils.php
0 → 100644
View file @
c971d5f3
<?php
namespace
app\api\untils
;
use
think\Session
;
/**
* Created by fuju
* User : hj
* Date : 2017-12-8
* Time : 16:34:07
* Intro:
*/
class
JwtUntils
{
/**
* 生成authToken
* @param type $data
* @return boolean
*/
public
function
createToken
(
$data
){
if
(
$data
)
{
$result
=
\Firebase\JWT\JWT
::
encode
(
$data
,
config
(
'jwt_key'
));
Session
::
set
(
'authToken'
,
$result
);
}
else
{
$result
=
false
;
}
return
$result
;
}
}
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