Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
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
Vũ Hoàng Anh
canifa_note
Commits
b6f7a85a
Unverified
Commit
b6f7a85a
authored
Dec 28, 2022
by
boojack
Committed by
GitHub
Dec 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: reload page when sign out (#871)
parent
3556ae4e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
18 deletions
+15
-18
auth.go
server/auth.go
+13
-14
UserBanner.tsx
web/src/components/UserBanner.tsx
+2
-3
user.ts
web/src/store/module/user.ts
+0
-1
No files found.
server/auth.go
View file @
b6f7a85a
...
@@ -54,20 +54,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
...
@@ -54,20 +54,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
return
nil
return
nil
})
})
g
.
POST
(
"/auth/logout"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
err
:=
removeUserSession
(
c
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to set logout session"
)
.
SetInternal
(
err
)
}
s
.
Collector
.
Collect
(
ctx
,
&
metric
.
Metric
{
Name
:
"user logout"
,
})
c
.
Response
()
.
WriteHeader
(
http
.
StatusOK
)
return
nil
})
g
.
POST
(
"/auth/signup"
,
func
(
c
echo
.
Context
)
error
{
g
.
POST
(
"/auth/signup"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
ctx
:=
c
.
Request
()
.
Context
()
signup
:=
&
api
.
Signup
{}
signup
:=
&
api
.
Signup
{}
...
@@ -143,4 +129,17 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
...
@@ -143,4 +129,17 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
}
}
return
nil
return
nil
})
})
g
.
POST
(
"/auth/logout"
,
func
(
c
echo
.
Context
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
err
:=
removeUserSession
(
c
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to set logout session"
)
.
SetInternal
(
err
)
}
s
.
Collector
.
Collect
(
ctx
,
&
metric
.
Metric
{
Name
:
"user logout"
,
})
return
c
.
JSON
(
http
.
StatusOK
,
true
)
})
}
}
web/src/components/UserBanner.tsx
View file @
b6f7a85a
import
{
useCallback
,
useEffect
,
useState
}
from
"react"
;
import
{
useCallback
,
useEffect
,
useState
}
from
"react"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useTranslation
}
from
"react-i18next"
;
import
{
useNavigate
}
from
"react-router-dom"
;
import
{
useLocationStore
,
useMemoStore
,
useTagStore
,
useUserStore
}
from
"../store/module"
;
import
{
useLocationStore
,
useMemoStore
,
useTagStore
,
useUserStore
}
from
"../store/module"
;
import
{
getMemoStats
}
from
"../helpers/api"
;
import
{
getMemoStats
}
from
"../helpers/api"
;
import
*
as
utils
from
"../helpers/utils"
;
import
*
as
utils
from
"../helpers/utils"
;
...
@@ -13,7 +12,6 @@ import "../less/user-banner.less";
...
@@ -13,7 +12,6 @@ import "../less/user-banner.less";
const
UserBanner
=
()
=>
{
const
UserBanner
=
()
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
navigate
=
useNavigate
();
const
locationStore
=
useLocationStore
();
const
locationStore
=
useLocationStore
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
memoStore
=
useMemoStore
();
const
memoStore
=
useMemoStore
();
...
@@ -66,7 +64,8 @@ const UserBanner = () => {
...
@@ -66,7 +64,8 @@ const UserBanner = () => {
};
};
const
handleSignOutBtnClick
=
async
()
=>
{
const
handleSignOutBtnClick
=
async
()
=>
{
navigate
(
"/auth"
);
await
userStore
.
doSignOut
();
window
.
location
.
href
=
"/auth"
;
};
};
return
(
return
(
...
...
web/src/store/module/user.ts
View file @
b6f7a85a
...
@@ -92,7 +92,6 @@ const doSignIn = async () => {
...
@@ -92,7 +92,6 @@ const doSignIn = async () => {
};
};
const
doSignOut
=
async
()
=>
{
const
doSignOut
=
async
()
=>
{
store
.
dispatch
(
setUser
());
await
api
.
signout
();
await
api
.
signout
();
};
};
...
...
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