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
e36e5823
Unverified
Commit
e36e5823
authored
Jul 17, 2023
by
Alexandr Tumaykin
Committed by
GitHub
Jul 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(security): disable access for anonymous users, when disablePublicMemos is true (#1966)
parent
4ac63ba1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
29 deletions
+53
-29
Header.tsx
web/src/components/Header.tsx
+16
-12
index.tsx
web/src/router/index.tsx
+37
-17
No files found.
web/src/components/Header.tsx
View file @
e36e5823
...
@@ -95,20 +95,24 @@ const Header = () => {
...
@@ -95,20 +95,24 @@ const Header = () => {
</
NavLink
>
</
NavLink
>
</>
</>
)
}
)
}
<
NavLink
{
!
isVisitorMode
&&
(
to=
"/explore"
id=
"header-explore"
className=
{
({
isActive
})
=>
classNames
(
"px-4 pr-5 py-2 rounded-full border flex flex-row items-center text-lg text-gray-800 dark:text-gray-300 hover:bg-white hover:border-gray-200 dark:hover:border-zinc-600 dark:hover:bg-zinc-700"
,
isActive
?
"bg-white dark:bg-zinc-700 border-gray-200 dark:border-zinc-600"
:
"border-transparent"
)
}
>
<>
<>
<
Icon
.
Hash
className=
"mr-3 w-6 h-auto opacity-70"
/>
{
t
(
"common.explore"
)
}
<
NavLink
to=
"/explore"
id=
"header-explore"
className=
{
({
isActive
})
=>
classNames
(
"px-4 pr-5 py-2 rounded-full border flex flex-row items-center text-lg text-gray-800 dark:text-gray-300 hover:bg-white hover:border-gray-200 dark:hover:border-zinc-600 dark:hover:bg-zinc-700"
,
isActive
?
"bg-white dark:bg-zinc-700 border-gray-200 dark:border-zinc-600"
:
"border-transparent"
)
}
>
<>
<
Icon
.
Hash
className=
"mr-3 w-6 h-auto opacity-70"
/>
{
t
(
"common.explore"
)
}
</>
</
NavLink
>
</>
</>
</
NavLink
>
)
}
{
!
isVisitorMode
&&
(
{
!
isVisitorMode
&&
(
<>
<>
...
...
web/src/router/index.tsx
View file @
e36e5823
...
@@ -64,10 +64,14 @@ const router = createBrowserRouter([
...
@@ -64,10 +64,14 @@ const router = createBrowserRouter([
}
}
const
{
host
,
user
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
))
{
if
(
isNullorUndefined
(
host
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
else
if
(
isNullorUndefined
(
user
))
{
}
else
if
(
isNullorUndefined
(
user
)
&&
!
systemStatus
.
disablePublicMemos
)
{
return
redirect
(
"/explore"
);
return
redirect
(
"/explore"
);
}
else
if
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
)
{
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
},
},
...
@@ -84,8 +88,10 @@ const router = createBrowserRouter([
...
@@ -84,8 +88,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -103,8 +109,10 @@ const router = createBrowserRouter([
...
@@ -103,8 +109,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -122,8 +130,10 @@ const router = createBrowserRouter([
...
@@ -122,8 +130,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -141,8 +151,10 @@ const router = createBrowserRouter([
...
@@ -141,8 +151,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -160,8 +172,10 @@ const router = createBrowserRouter([
...
@@ -160,8 +172,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -180,8 +194,10 @@ const router = createBrowserRouter([
...
@@ -180,8 +194,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -199,8 +215,10 @@ const router = createBrowserRouter([
...
@@ -199,8 +215,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
@@ -220,8 +238,10 @@ const router = createBrowserRouter([
...
@@ -220,8 +238,10 @@ const router = createBrowserRouter([
// do nth
// do nth
}
}
const
{
host
}
=
store
.
getState
().
user
;
const
{
host
,
user
}
=
store
.
getState
().
user
;
if
(
isNullorUndefined
(
host
))
{
const
{
systemStatus
}
=
store
.
getState
().
global
;
if
(
isNullorUndefined
(
host
)
||
(
isNullorUndefined
(
user
)
&&
systemStatus
.
disablePublicMemos
))
{
return
redirect
(
"/auth"
);
return
redirect
(
"/auth"
);
}
}
return
null
;
return
null
;
...
...
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