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
30b071f3
Commit
30b071f3
authored
Mar 18, 2022
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
327de006
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
21 deletions
+9
-21
OssController.php
api/controllers/OssController.php
+2
-6
OssController.php
backend/controllers/OssController.php
+2
-6
Admin.php
common/models/Admin.php
+1
-1
OssController.php
wallet/controllers/OssController.php
+2
-6
UserController.php
wallet/controllers/UserController.php
+2
-2
No files found.
api/controllers/OssController.php
View file @
30b071f3
...
@@ -9,10 +9,6 @@ use api\base\BaseController;
...
@@ -9,10 +9,6 @@ use api\base\BaseController;
class
OssController
extends
BaseController
class
OssController
extends
BaseController
{
{
protected
$accessKeyId
=
"LTAI5tMEAZrqSPSUuUcHEuR1"
;
protected
$accessKeySecret
=
"dGtX1Sh8jatB1nFh6kOWYDIIeljcin"
;
protected
$endpoint
=
"http://oss-cn-shanghai.aliyuncs.com"
;
protected
$bucket
=
"bqbwallet"
;
public
function
actionUpload
()
public
function
actionUpload
()
{
{
...
@@ -25,8 +21,8 @@ class OssController extends BaseController
...
@@ -25,8 +21,8 @@ class OssController extends BaseController
}
}
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$filePath
=
$uploaded_file
->
tempName
;
$filePath
=
$uploaded_file
->
tempName
;
$ossClient
=
new
OssClient
(
$this
->
accessKeyId
,
$this
->
accessKeySecret
,
$this
->
endpoint
);
$ossClient
=
new
OssClient
(
Yii
::
$app
->
params
[
'Oss'
][
'AccessKeyId'
],
Yii
::
$app
->
params
[
'Oss'
][
'AccessKeySecret'
],
Yii
::
$app
->
params
[
'Oss'
][
'Endpoint'
]
);
$result
=
$ossClient
->
uploadFile
(
$this
->
bucket
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
$result
=
$ossClient
->
uploadFile
(
Yii
::
$app
->
params
[
'Bucket'
]
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
$this
->
msg
=
'上传失败'
;
$this
->
msg
=
'上传失败'
;
$this
->
code
=
-
1
;
$this
->
code
=
-
1
;
...
...
backend/controllers/OssController.php
View file @
30b071f3
...
@@ -10,10 +10,6 @@ use yii\validators\ImageValidator;
...
@@ -10,10 +10,6 @@ use yii\validators\ImageValidator;
class
OssController
extends
BaseController
class
OssController
extends
BaseController
{
{
protected
$accessKeyId
=
"LTAI5tMEAZrqSPSUuUcHEuR1"
;
protected
$accessKeySecret
=
"dGtX1Sh8jatB1nFh6kOWYDIIeljcin"
;
protected
$endpoint
=
"http://oss-cn-shanghai.aliyuncs.com"
;
protected
$bucket
=
"bqbwallet"
;
public
function
actionUpload
()
public
function
actionUpload
()
{
{
...
@@ -22,8 +18,8 @@ class OssController extends BaseController
...
@@ -22,8 +18,8 @@ class OssController extends BaseController
$uploaded_file
=
UploadedFile
::
getInstanceByName
(
'file'
);
$uploaded_file
=
UploadedFile
::
getInstanceByName
(
'file'
);
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$filePath
=
$uploaded_file
->
tempName
;
$filePath
=
$uploaded_file
->
tempName
;
$ossClient
=
new
OssClient
(
$this
->
accessKeyId
,
$this
->
accessKeySecret
,
$this
->
endpoint
);
$ossClient
=
new
OssClient
(
Yii
::
$app
->
params
[
'Oss'
][
'AccessKeyId'
],
Yii
::
$app
->
params
[
'Oss'
][
'AccessKeySecret'
],
Yii
::
$app
->
params
[
'Oss'
][
'Endpoint'
]
);
$result
=
$ossClient
->
uploadFile
(
$this
->
bucket
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
$result
=
$ossClient
->
uploadFile
(
Yii
::
$app
->
params
[
'Bucket'
]
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
return
[
'code'
=>
1
,
'msg'
=>
'上传失败'
];
return
[
'code'
=>
1
,
'msg'
=>
'上传失败'
];
}
}
...
...
common/models/Admin.php
View file @
30b071f3
...
@@ -178,7 +178,7 @@ class Admin extends \common\modelsgii\Admin implements IdentityInterface
...
@@ -178,7 +178,7 @@ class Admin extends \common\modelsgii\Admin implements IdentityInterface
public
static
function
verfication
(
$accessToken
)
public
static
function
verfication
(
$accessToken
)
{
{
$key
=
'bwallet'
;
//key要和签发的时候一样
$key
=
Yii
::
$app
->
params
[
'Jwt'
][
'Key'
];
//key要和签发的时候一样
try
{
try
{
JWT
::
$leeway
=
60
;
//当前时间减去60,把时间留点余地
JWT
::
$leeway
=
60
;
//当前时间减去60,把时间留点余地
$decoded
=
JWT
::
decode
(
$accessToken
,
$key
,
[
'HS256'
]);
//HS256方式,这里要和签发的时候对应
$decoded
=
JWT
::
decode
(
$accessToken
,
$key
,
[
'HS256'
]);
//HS256方式,这里要和签发的时候对应
...
...
wallet/controllers/OssController.php
View file @
30b071f3
...
@@ -9,10 +9,6 @@ use wallet\base\BaseController;
...
@@ -9,10 +9,6 @@ use wallet\base\BaseController;
class
OssController
extends
BaseController
class
OssController
extends
BaseController
{
{
protected
$accessKeyId
=
"LTAI5tMEAZrqSPSUuUcHEuR1"
;
protected
$accessKeySecret
=
"dGtX1Sh8jatB1nFh6kOWYDIIeljcin"
;
protected
$endpoint
=
"http://oss-cn-shanghai.aliyuncs.com"
;
protected
$bucket
=
"bqbwallet"
;
public
function
actionUpload
()
public
function
actionUpload
()
{
{
...
@@ -26,8 +22,8 @@ class OssController extends BaseController
...
@@ -26,8 +22,8 @@ class OssController extends BaseController
}
}
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$object
=
md5
(
date
(
'Y-m-d H:i:s'
)
.
$uploaded_file
->
tempName
)
.
'.'
.
$uploaded_file
->
extension
;
$filePath
=
$uploaded_file
->
tempName
;
$filePath
=
$uploaded_file
->
tempName
;
$ossClient
=
new
OssClient
(
$this
->
accessKeyId
,
$this
->
accessKeySecret
,
$this
->
endpoint
);
$ossClient
=
new
OssClient
(
Yii
::
$app
->
params
[
'Oss'
][
'AccessKeyId'
],
Yii
::
$app
->
params
[
'Oss'
][
'AccessKeySecret'
],
Yii
::
$app
->
params
[
'Oss'
][
'Endpoint'
]
);
$result
=
$ossClient
->
uploadFile
(
$this
->
bucket
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
$result
=
$ossClient
->
uploadFile
(
Yii
::
$app
->
params
[
'Bucket'
]
,
'upload/'
.
(
empty
(
$type
)
?
''
:
$type
.
'/'
)
.
$object
,
$filePath
);
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
if
(
!
isset
(
$result
[
"info"
][
'url'
]))
{
$msg
=
'上传失败'
;
$msg
=
'上传失败'
;
$code
=
-
1
;
$code
=
-
1
;
...
...
wallet/controllers/UserController.php
View file @
30b071f3
...
@@ -41,8 +41,8 @@ class UserController extends BaseController
...
@@ -41,8 +41,8 @@ class UserController extends BaseController
goto
doEnd
;
goto
doEnd
;
}
}
$token
=
[
$token
=
[
'iss'
=>
'https://www.bitfeel.cn'
,
//签发者 可选
'iss'
=>
Yii
::
$app
->
params
[
'Jwt'
][
'Iss'
]
,
//签发者 可选
'aud'
=>
'https://www.bitfeel.cn'
,
//接收该JWT的一方,可选
'aud'
=>
Yii
::
$app
->
params
[
'Jwt'
][
'Aud'
]
,
//接收该JWT的一方,可选
'iat'
=>
time
(),
//签发时间
'iat'
=>
time
(),
//签发时间
'nbf'
=>
$time
,
//(Not Before):某个时间点后才能访问,比如设置time+30,表示当前时间30秒后才能使用
'nbf'
=>
$time
,
//(Not Before):某个时间点后才能访问,比如设置time+30,表示当前时间30秒后才能使用
'exp'
=>
$time
+
7200
,
//过期时间,这里设置2个小时
'exp'
=>
$time
+
7200
,
//过期时间,这里设置2个小时
...
...
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