Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
red-giant
dashboard
Commits
bbb9b6c9
Verified
Commit
bbb9b6c9
authored
3 years ago
by
Defendi Alberto
Browse files
Options
Downloads
Patches
Plain Diff
Move back cookie fetch to SignInForm.
This cookie has to be sent only from this page.
parent
9f9e4ee8
No related branches found
Branches containing commit
Tags
v0.1.0
Tags containing commit
2 merge requests
!56
Refined auth flow and new website pages.
,
!43
Move back cookie fetch to SignInForm. Role fetched and saved into a Context. Small refactorings.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/App.tsx
+2
-24
2 additions, 24 deletions
src/App.tsx
with
2 additions
and
24 deletions
src/App.tsx
+
2
−
24
View file @
bbb9b6c9
...
@@ -9,7 +9,6 @@ import { NotFound } from 'components/NonAuthUser/NotFound/NotFound';
...
@@ -9,7 +9,6 @@ import { NotFound } from 'components/NonAuthUser/NotFound/NotFound';
import
{
ProfilePage
}
from
'
components/AuthUser/ProfilePage/ProfilePage
'
;
import
{
ProfilePage
}
from
'
components/AuthUser/ProfilePage/ProfilePage
'
;
import
{
Roles
}
from
'
api/userRoles
'
;
import
{
Roles
}
from
'
api/userRoles
'
;
import
{
Unauthorized
}
from
'
components/NonAuthUser/Unauthorized/Unauthorized
'
;
import
{
Unauthorized
}
from
'
components/NonAuthUser/Unauthorized/Unauthorized
'
;
import
axios
from
'
axios
'
;
import
{
ReservationPage
}
from
'
components/AuthUser/ReservationPage/ReservationPage
'
;
import
{
ReservationPage
}
from
'
components/AuthUser/ReservationPage/ReservationPage
'
;
import
{
HomePage
}
from
'
components/AuthUser/HomePage/HomePage
'
;
import
{
HomePage
}
from
'
components/AuthUser/HomePage/HomePage
'
;
import
{
SignInForm
}
from
'
components/AuthUser/SignInForm/SignInForm
'
;
import
{
SignInForm
}
from
'
components/AuthUser/SignInForm/SignInForm
'
;
...
@@ -43,31 +42,10 @@ const theme = createMuiTheme({
...
@@ -43,31 +42,10 @@ const theme = createMuiTheme({
},
},
});
});
const
configDjangoCookieName
=
():
void
=>
{
axios
.
defaults
.
xsrfHeaderName
=
'
X-CSRFTOKEN
'
;
axios
.
defaults
.
xsrfCookieName
=
'
csrftoken
'
;
axios
.
defaults
.
withCredentials
=
true
;
};
export
const
App
:
FC
=
()
=>
{
export
const
App
:
FC
=
()
=>
{
const
[
isCookieFetched
,
setisCookieFetched
]
=
useState
<
string
>
(
''
);
const
[
role
,
setRole
]
=
useState
(
''
);
const
[
role
,
setRole
]
=
useState
(
''
);
const
value
=
{
role
,
setRole
};
const
value
=
{
role
,
setRole
};
configDjangoCookieName
();
useEffect
(()
=>
{
const
fetchCookie
=
async
():
Promise
<
unknown
>
=>
{
const
response
=
await
axios
(
'
api/web/csrf
'
);
axios
.
defaults
.
headers
.
common
[
'
X-CSRFTOKEN
'
]
=
response
.
data
.
token
;
sessionStorage
.
setItem
(
'
X-CSRFTOKEN
'
,
response
.
data
.
token
);
sessionStorage
.
setItem
(
'
ROLE
'
,
'
admin
'
);
setisCookieFetched
(
response
.
data
.
token
);
return
null
;
};
if
(
!
isCookieFetched
)
fetchCookie
();
},
[
isCookieFetched
]);
return
(
return
(
<
ThemeProvider
theme
=
{
theme
}
>
<
ThemeProvider
theme
=
{
theme
}
>
<
Router
>
<
Router
>
...
@@ -75,9 +53,9 @@ export const App: FC = () => {
...
@@ -75,9 +53,9 @@ export const App: FC = () => {
<
Switch
>
<
Switch
>
<
Route
exact
path
=
{
NonAuthRoutes
.
home
}
component
=
{
LandingPage
}
/>
<
Route
exact
path
=
{
NonAuthRoutes
.
home
}
component
=
{
LandingPage
}
/>
<
AuthContext
.
Provider
value
=
{
value
}
>
<
AuthContext
.
Provider
value
=
{
value
}
>
<
Route
exact
path
=
{
NonAuthRoutes
.
auth
}
component
=
{
AuthUser
}
/>
<
Route
path
=
{
NonAuthRoutes
.
auth
}
component
=
{
AuthUser
}
/>
<
Route
exact
path
=
"/signIn"
component
=
{
SignInForm
}
/>
<
Route
path
=
"/signIn"
component
=
{
SignInForm
}
/>
<
PrivateRoute
<
PrivateRoute
path
=
{
AuthRoutes
.
dashboard
}
path
=
{
AuthRoutes
.
dashboard
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment