Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doc_phone
Project
Project
Details
Activity
Releases
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
jiangyipeng
doc_phone
Commits
19ffa479
Commit
19ffa479
authored
May 27, 2020
by
huanle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0527. token
parent
ddf7d445
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
Index.php
application/login/controller/Index.php
+13
-7
No files found.
application/login/controller/Index.php
View file @
19ffa479
<?php
<?php
namespace
app\login\controller
;
namespace
app\login\controller
;
use
app\login\model\Token
as
TokenModel
;
use
app\login\model\Token
as
TokenModel
;
use
cjango\Dingtalk\User
;
use
src\Dingtalk\Utils
;
use
src\Dingtalk\Utils
;
use
think\Controller
;
use
think\Controller
;
use
think\Db
;
use
think\Db
;
...
@@ -42,17 +41,16 @@ class Index extends Controller
...
@@ -42,17 +41,16 @@ class Index extends Controller
return
json
(
code
([
$config
],
0
,
'ok'
));
return
json
(
code
([
$config
],
0
,
'ok'
));
//return json($data);
//return json($data);
}
}
public
function
getSsoToken
(){
public
function
login
(){
$code
=
input
(
'post.code'
);
$code
=
input
(
'post.code'
);
//var_dump($code);
//var_dump($code);
//$access_token= Session::get('access_token');
//$access_token= Session::get('access_token');
$User
=
new
Dingtalk\User
();
$User
=
new
Dingtalk\User
();
$userid
=
$User
->
code
(
$code
);
$userid
=
$User
->
code
(
$code
);
$result
=
$this
->
create
(
$userid
);
$token
=
new
Token
();
$gettoken
=
$token
->
create
(
$userid
);
if
(
$userid
===
false
){
if
(
$userid
===
false
){
$data
[
'status'
]
=-
10001
;
$data
[
'status'
]
=-
10001
;
$data
[
'errmsg'
]
=
'登录失败'
;
$data
[
'errmsg'
]
=
'登录失败'
;
...
@@ -60,12 +58,20 @@ class Index extends Controller
...
@@ -60,12 +58,20 @@ class Index extends Controller
$data
[
'status'
]
=
0
;
$data
[
'status'
]
=
0
;
$data
[
'errmsg'
]
=
'登录成功'
;
$data
[
'errmsg'
]
=
'登录成功'
;
$data
[
'userid'
]
=
$userid
;
$data
[
'userid'
]
=
$userid
;
$data
[
'token'
]
=
$result
;
}
}
// return json($data);
// return json($data);
return
json
(
code
([
$data
],
0
,
'ok'
));
return
json
(
code
([
$data
],
0
,
'ok'
));
// var_dump($_SESSION);
}
}
public
function
checkToken
(){
public
function
create
(
$uid
)
{
$tokenModel
=
new
TokenModel
();
$token
=
$tokenModel
->
createToken
(
$uid
);
if
(
$token
==
false
)
{
return
json
(
code
([],
$tokenModel
->
getErrCode
(),
$tokenModel
->
getError
()));
}
else
{
return
json
(
code
([
'token'
=>
$token
,
'expire_second'
=>
config
(
'token_expire_second'
)]));
}
}
}
}
}
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