Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
API Toucan
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
Container registry
Model registry
Operate
Environments
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
Damien Armillon
API Toucan
Commits
8e0ec185
Commit
8e0ec185
authored
6 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
Oauth for the front
parent
3e597060
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
front/src/App.js
+3
-2
3 additions, 2 deletions
front/src/App.js
front/src/utils/Oauth.js
+9
-0
9 additions, 0 deletions
front/src/utils/Oauth.js
front/src/view/Login.js
+2
-1
2 additions, 1 deletion
front/src/view/Login.js
with
14 additions
and
3 deletions
front/src/App.js
+
3
−
2
View file @
8e0ec185
import
React
from
'
react
'
;
import
{
BrowserRouter
as
Router
,
Route
,
Redirect
}
from
'
react-router-dom
'
;
import
{
BrowserRouter
as
Router
,
Route
}
from
'
react-router-dom
'
;
import
'
./App.css
'
;
import
MainPage
from
'
./view/mainPage
'
;
import
Login
from
'
./view/Login
'
;
import
env
from
'
./.env
'
import
isLogged
from
'
./utils/Oauth
'
;
function
App
()
{
return
(
<
Router
>
<
Route
exact
path
=
'
/
'
render
=
{()
=>
false
?
<
MainPage
/>
:
window
.
location
=
`
${
env
.
backURL
}
/oauth/login`
}
/
>
<
Route
exact
path
=
'
/
'
render
=
{()
=>
isLogged
()
?
<
MainPage
/>
:
window
.
location
=
`
${
env
.
backURL
}
/oauth/login`
}
/
>
<
Route
exact
path
=
'
/login/:token
'
component
=
{
Login
}
/
>
<
/Router
>
);
...
...
This diff is collapsed.
Click to expand it.
front/src/utils/Oauth.js
0 → 100644
+
9
−
0
View file @
8e0ec185
function
isLogged
()
{
let
token
=
localStorage
.
getItem
(
"
token
"
);
if
(
token
)
{
return
((
/^ey.*/
).
test
(
token
))
}
return
false
;
}
export
default
isLogged
;
This diff is collapsed.
Click to expand it.
front/src/view/Login.js
+
2
−
1
View file @
8e0ec185
...
...
@@ -5,12 +5,13 @@ class Login extends Component {
componentDidMount
(){
localStorage
.
setItem
(
"
token
"
,
this
.
props
.
match
.
params
.
token
);
console
.
log
(
localStorage
.
getItem
(
"
token
"
));
window
.
location
=
'
/
'
;
}
render
(){
return
(
<
div
>
tesst
<
/div
>
<
div
>
Vous
allez
être
redirigé
<
/div
>
)
}
}
...
...
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