Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thecybernanny-webapp
Project
Overview
Details
Activity
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
asranov0003
thecybernanny-webapp
Commits
2e59e28f
Commit
2e59e28f
authored
Jul 12, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add auth logout logic
parent
127f1e19
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
Header.tsx
src/layouts/Header/Header.tsx
+2
-1
authSlice.ts
src/stores/slices/authSlice.ts
+7
-7
No files found.
src/layouts/Header/Header.tsx
View file @
2e59e28f
...
...
@@ -24,6 +24,7 @@ import {
setSelectedDevice
,
}
from
"../../stores/slices/deviceSlice"
;
import
CDeviceSelect
from
"../../components/CDeviceSelect"
;
import
{
logout
}
from
"../../stores/slices/authSlice"
;
const
Header
:
React
.
FC
=
()
=>
{
const
[
isSidebarOpen
,
setIsSidebarOpen
]
=
useState
(
false
);
...
...
@@ -160,7 +161,7 @@ const Header: React.FC = () => {
</
div
>
</
div
>
<
div
className=
"sidebar__logout"
>
<
div
className=
"sidebar__logout"
onClick=
{
()
=>
dispatch
(
logout
())
}
>
<
MdLogout
className=
"sidebar__logout__icon"
/>
<
span
>
{
t
(
"navs.logout"
)
}
</
span
>
</
div
>
...
...
src/stores/slices/authSlice.ts
View file @
2e59e28f
...
...
@@ -4,6 +4,7 @@ import {
type
PayloadAction
,
}
from
"@reduxjs/toolkit"
;
import
{
sendRpcRequest
}
from
"../../services/apiClient"
;
import
{
TG_USER_ID
}
from
"../../constants/constants"
;
interface
IAuthUser
{
token
:
string
;
...
...
@@ -87,12 +88,11 @@ const authSlice = createSlice({
name
:
"auth"
,
initialState
,
reducers
:
{
logout
(
state
)
{
state
.
user
=
null
;
},
clearStatus
(
state
)
{
state
.
error
=
null
;
state
.
success
=
false
;
logout
()
{
localStorage
.
removeItem
(
`token-
${
TG_USER_ID
}
`
);
localStorage
.
removeItem
(
`pincode-
${
TG_USER_ID
}
`
);
sessionStorage
.
removeItem
(
`pincode-
${
TG_USER_ID
}
`
);
window
.
location
.
href
=
"/"
;
},
},
extraReducers
:
(
builder
)
=>
{
...
...
@@ -150,5 +150,5 @@ const authSlice = createSlice({
},
});
export
const
{
logout
,
clearStatus
}
=
authSlice
.
actions
;
export
const
{
logout
}
=
authSlice
.
actions
;
export
default
authSlice
.
reducer
;
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