Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
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
Евгений Положенцев
planner-team-one
Commits
d56280a9
Commit
d56280a9
authored
Nov 05, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#10
Утвердился, что все работает
parent
b0374cba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
7 deletions
+5
-7
App.js
planner-front/src/App.js
+4
-3
Login.js
planner-front/src/containers/Login/Login.js
+0
-1
usersActions.js
planner-front/src/store/actions/usersActions.js
+0
-2
usersReducer.js
planner-front/src/store/reducers/usersReducer.js
+1
-1
No files found.
planner-front/src/App.js
View file @
d56280a9
import
{
Routes
,
Route
,
Outlet
,
Navigate
,
BrowserRouter
}
from
"react-router-dom"
;
import
{
Routes
,
Route
,
Outlet
,
Navigate
,
BrowserRouter
}
from
"react-router-dom"
;
import
{
Container
}
from
"@mui/material"
;
import
{
Container
}
from
"@mui/material"
;
import
{
useSelector
}
from
"react-redux"
;
import
{
useSelector
}
from
"react-redux"
;
import
AppToolbar
from
"./components/UI/AppToolBar/AppToolBar"
;
import
AppToolbar
from
'./components/UI/AppToolBar/AppToolbar'
import
MyTasks
from
'./containers/MyTasks/MyTasks'
import
Login
from
'./containers/Login/Login'
import
Register
from
'./containers/Register/Register'
const
ProtectedRoute
=
({
isAllowed
,
roles
,
redirectUrl
,
children
})
=>
{
const
ProtectedRoute
=
({
isAllowed
,
roles
,
redirectUrl
,
children
})
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
console
.
log
(
user
)
if
(
!
isAllowed
&&
!
roles
?.
includes
(
user
?.
role
))
{
if
(
!
isAllowed
&&
!
roles
?.
includes
(
user
?.
role
))
{
return
<
Navigate
to
=
{
redirectUrl
}
/
>
return
<
Navigate
to
=
{
redirectUrl
}
/
>
}
}
...
@@ -14,7 +16,6 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => {
...
@@ -14,7 +16,6 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => {
const
App
=
()
=>
{
const
App
=
()
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
console
.
log
(
user
)
return
(
return
(
<
BrowserRouter
>
<
BrowserRouter
>
<
Routes
>
<
Routes
>
...
...
planner-front/src/containers/Login/Login.js
View file @
d56280a9
...
@@ -30,7 +30,6 @@ const Login = () => {
...
@@ -30,7 +30,6 @@ const Login = () => {
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
{
loginError
,
loading
}
=
useSelector
(
state
=>
state
.
users
);
const
{
loginError
,
loading
}
=
useSelector
(
state
=>
state
.
users
);
console
.
log
(
loginError
)
const
navigate
=
useNavigate
(
"/"
)
const
navigate
=
useNavigate
(
"/"
)
const
inputChangeHandler
=
(
e
)
=>
{
const
inputChangeHandler
=
(
e
)
=>
{
...
...
planner-front/src/store/actions/usersActions.js
View file @
d56280a9
...
@@ -20,7 +20,6 @@ export const registerUser = (userData, navigate) => {
...
@@ -20,7 +20,6 @@ export const registerUser = (userData, navigate) => {
try
{
try
{
const
response
=
await
axios
.
post
(
"/users"
,
userData
);
const
response
=
await
axios
.
post
(
"/users"
,
userData
);
dispatch
(
registerUserSuccess
())
dispatch
(
registerUserSuccess
())
console
.
log
(
response
)
navigate
(
"/"
)
navigate
(
"/"
)
}
catch
(
error
)
{
}
catch
(
error
)
{
if
(
error
.
response
?.
data
)
{
if
(
error
.
response
?.
data
)
{
...
@@ -54,7 +53,6 @@ export const loginUser = (userData, navigate) => {
...
@@ -54,7 +53,6 @@ export const loginUser = (userData, navigate) => {
dispatch
(
loginUserSuccess
(
response
.
data
));
dispatch
(
loginUserSuccess
(
response
.
data
));
navigate
(
"/"
)
navigate
(
"/"
)
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
dir
(
e
)
dispatch
(
loginUserFailure
(
e
?.
response
?.
data
?.
err
))
dispatch
(
loginUserFailure
(
e
?.
response
?.
data
?.
err
))
}
}
}
}
...
...
planner-front/src/store/reducers/usersReducer.js
View file @
d56280a9
...
@@ -5,7 +5,7 @@ const initialState = {
...
@@ -5,7 +5,7 @@ const initialState = {
name
:
'Ivan'
,
name
:
'Ivan'
,
surname
:
'Petrov'
,
surname
:
'Petrov'
,
email
:
'test@gmail.com'
,
email
:
'test@gmail.com'
,
role
:
'
super
user'
role
:
'user'
},
},
registerError
:
null
,
registerError
:
null
,
loginError
:
null
,
loginError
:
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