Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
849f944f
Commit
849f944f
authored
Dec 11, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
c3fde027
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
+8
-7
jwt.go
middleware/jwt/jwt.go
+1
-1
code.go
pkg/e/code.go
+4
-4
jwt.go
pkg/util/jwt.go
+1
-1
router.go
routers/router.go
+2
-1
No files found.
middleware/jwt/jwt.go
View file @
849f944f
...
...
@@ -14,7 +14,7 @@ func JWT() gin.HandlerFunc {
var
data
interface
{}
code
=
e
.
SUCCESS
token
:=
c
.
GetHeader
(
"t
oken"
)
token
:=
c
.
Request
.
Header
.
Get
(
"T
oken"
)
if
token
==
""
{
code
=
e
.
INVALID_PARAMS
}
else
{
...
...
pkg/e/code.go
View file @
849f944f
...
...
@@ -26,10 +26,10 @@ const (
ERROR_GET_ARTICLE_FAIL
=
10018
ERROR_GEN_ARTICLE_POSTER_FAIL
=
10019
ERROR_AUTH_CHECK_TOKEN_FAIL
=
2
0001
ERROR_AUTH_CHECK_TOKEN_TIMEOUT
=
2
0002
ERROR_AUTH_TOKEN
=
2
0003
ERROR_AUTH
=
2
0004
ERROR_AUTH_CHECK_TOKEN_FAIL
=
4
0001
ERROR_AUTH_CHECK_TOKEN_TIMEOUT
=
4
0002
ERROR_AUTH_TOKEN
=
4
0003
ERROR_AUTH
=
4
0004
ERROR_UPLOAD_SAVE_IMAGE_FAIL
=
30001
ERROR_UPLOAD_CHECK_IMAGE_FAIL
=
30002
...
...
pkg/util/jwt.go
View file @
849f944f
...
...
@@ -22,7 +22,7 @@ func GenerateToken(username, password string) (string, error) {
EncodeMD5
(
password
),
jwt
.
StandardClaims
{
ExpiresAt
:
expireTime
.
Unix
(),
Issuer
:
"
gin-blog
"
,
Issuer
:
"
bwallet
"
,
},
}
...
...
routers/router.go
View file @
849f944f
...
...
@@ -8,6 +8,7 @@ import (
"bwallet/pkg/qrcode"
"bwallet/routers/api"
"bwallet/routers/api/v1"
"bwallet/middleware/jwt"
)
func
InitRouter
()
*
gin
.
Engine
{
...
...
@@ -24,7 +25,7 @@ func InitRouter() *gin.Engine {
r
.
POST
(
"/upload"
,
api
.
UploadImage
)
apiv1
:=
r
.
Group
(
"/api"
)
//
apiv1.Use(jwt.JWT())
apiv1
.
Use
(
jwt
.
JWT
())
{
apiv1
.
GET
(
"/coins"
,
v1
.
GetCoins
)
...
...
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