Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DBMS inventory manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Shrey Patel
DBMS inventory manager
Commits
68f2aca6
Commit
68f2aca6
authored
1 year ago
by
Sarthak Shrivastava
Browse files
Options
Downloads
Patches
Plain Diff
mostly working authentication + user updating code
parent
fd89b77e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory-manager/src/App.jsx
+10
-7
10 additions, 7 deletions
inventory-manager/src/App.jsx
inventory-manager/src/routes/ProtectedRoute.jsx
+12
-0
12 additions, 0 deletions
inventory-manager/src/routes/ProtectedRoute.jsx
with
22 additions
and
7 deletions
inventory-manager/src/App.jsx
+
10
−
7
View file @
68f2aca6
...
...
@@ -11,26 +11,29 @@ import {
import
{
useState
}
from
"
react
"
;
import
useToken
from
"
./components/useToken
"
;
import
AccountInformation
from
"
./components/user/AccountInformation
"
;
import
ProtectedRoute
from
"
./routes/ProtectedRoute
"
;
function
App
()
{
// const [token, setToken] = useState();
const
{
token
,
setToken
}
=
useToken
();
// const token = getToken();
if
(
!
token
)
{
return
<
Login
setToken
=
{
setToken
}
/>
}
//
if (!token)
//
{
//
return <Login setToken={setToken}/>
//
}
return
(
<
div
className
=
"App"
>
<
Navbar
/>
<
Routes
>
<
Route
path
=
"/"
element
=
{
<
Home
/>
}
/>
<
Route
path
=
"/login"
element
=
{
<
Login
setToken
=
{
t
oken
}
/>
}
/>
<
Route
path
=
"/login"
element
=
{
<
Login
setToken
=
{
setT
oken
}
/>
}
/>
<
Route
path
=
"/register"
element
=
{
<
Register
/>
}
/>
<
Route
path
=
"/deleteUser"
element
=
{
<
DeleteUser
token
=
{
token
}
/>
}
/>
<
Route
path
=
'/accountinfo'
element
=
{
<
ProtectedRoute
token
=
{
token
}
>
<
AccountInformation
token
=
{
token
}
/>
</
ProtectedRoute
>
}
>
</
Route
>
{
/* <Route path="/deleteUser" element={<DeleteUser token={token}/>} />
<Route path="/updatepassword" element={<UpdatePassword />} />
<
Route
path
=
"/accountinfo"
element
=
{
<
AccountInformation
token
=
{
token
}
/>
}
/>
<Route path="/accountinfo" element={<AccountInformation token={token}/> } />
*/
}
</
Routes
>
</
div
>
);
...
...
This diff is collapsed.
Click to expand it.
inventory-manager/src/routes/ProtectedRoute.jsx
0 → 100644
+
12
−
0
View file @
68f2aca6
import
React
from
'
react
'
;
import
{
Route
,
Navigate
}
from
'
react-router-dom
'
;
const
ProtectedRoute
=
({
element
,
token
,
...
props
})
=>
{
return
token
?
(
<
Route
{
...
props
}
element
=
{
element
}
/>
)
:
(
<
Navigate
to
=
"/login"
/>
);
};
export
default
ProtectedRoute
;
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