Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
xuzhenhao
/
xuzhenhao-dev-icesimbapolysdklogin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 37159233
authored
Dec 13, 2017
by
xuzhenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了注销功能
1 parent
10ea3104
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
src/loginserver/apis/loginserver.go
src/loginserver/models/user.go
src/loginserver/apis/loginserver.go
View file @
3715923
...
...
@@ -66,9 +66,6 @@ func UserLoginApi(c *gin.Context) {
HttpOnly
:
true
,
Expires
:
time
.
Now
()
.
Add
(
2
*
time
.
Hour
),
}
// res := map[string]interface{}{
// "user_id": result.(map[string]interface{})["user_id"].(int),
// }
http
.
SetCookie
(
c
.
Writer
,
cookie
)
ReturnRespones
(
c
,
"0"
,
"authorize success"
)
return
...
...
@@ -150,6 +147,24 @@ func ChangeUserPasswordApi(c *gin.Context) {
return
}
//用户注销接口
func
UserLogoutApi
(
c
*
gin
.
Context
)
{
token
,
err
:=
c
.
Cookie
(
"icesimbaToken"
)
if
err
!=
nil
{
log
.
Println
(
err
)
ReturnRespones
(
c
,
"104000"
,
err
)
return
}
cookie
:=
&
http
.
Cookie
{
Name
:
"icesimbaToken"
,
Path
:
"/"
,
MaxAge
:
-
1
,
}
http
.
SetCookie
(
c
.
Writer
,
cookie
)
ReturnRespones
(
c
,
"0"
,
"成功注销"
)
return
}
//返回函数
func
ReturnRespones
(
c
*
gin
.
Context
,
code
string
,
result
interface
{})
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
...
...
src/loginserver/models/user.go
View file @
3715923
...
...
@@ -239,5 +239,10 @@ func CheckRequestToken(token string) (result interface{}, err error) {
err
=
errors
.
New
(
"token已失效"
)
return
"105005"
,
err
}
return
string
(
r
[
0
][
"user_id"
]),
nil
id
:=
string
(
r
[
0
][
"user_id"
])
idInt
,
err
:=
strconv
.
Atoi
(
id
)
if
err
!=
nil
{
return
"104000"
,
err
}
return
idInt
,
nil
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment