Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nicolas Pope
ftl
Commits
0f24d356
Commit
0f24d356
authored
5 years ago
by
Sami Spets
Browse files
Options
Downloads
Patches
Plain Diff
minor changes
parent
dca895c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#14013
passed
5 years ago
Stage: all
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
web-service/client/src/App.js
+11
-24
11 additions, 24 deletions
web-service/client/src/App.js
web-service/client/src/Login.js
+27
-0
27 additions, 0 deletions
web-service/client/src/Login.js
web-service/server/src/index.js
+2
-1
2 additions, 1 deletion
web-service/server/src/index.js
with
40 additions
and
25 deletions
web-service/client/src/App.js
+
11
−
24
View file @
0f24d356
...
...
@@ -2,10 +2,20 @@ import React, { useState } from 'react';
import
'
./App.css
'
//import {Route, BrowserRouter, Link} from 'react-router-domm
import
Streams
from
'
./Streams
'
import
Login
from
'
./Login
'
const
App
=
()
=>
{
const
[
user
,
setUser
]
=
useState
(
null
);
const
[
streams
,
setStreams
]
=
useState
(
null
);
/**
* TODO: create a list available of streams using useEffect.
* Each index is an object (stream) that has a name and a picture.
* When making the request for the objects the same request
* authenticates the users JWT
*
*/
const
handleLogin
=
()
=>
{
//BEFORE BUILD CHANGE THE URL TO /google
...
...
@@ -19,34 +29,11 @@ const App = () => {
if
(
window
.
localStorage
.
getItem
(
'
token
'
)){
return
(
/*
This should redirect the router path to point at /streams
So instead of the div down below it would render
<Streams />
*/
<
Streams
clearCookies
=
{
clearCookies
}
/
>
)
}
return
(
<
div
style
=
{{
'
padding-top
'
:
'
150px
'
,
'
text-align
'
:
'
center
'
}}
>
<
h2
>
Welcome
to
Future
Technology
Lab
<
/h2
>
<
h3
>
Please
login
!<
/h3
>
<
a
className
=
"
button
"
onClick
=
{
handleLogin
}
>
<
div
>
<
span
className
=
"
svgIcon t-popup-svg
"
>
<
svg
className
=
"
svgIcon-use
"
width
=
"
25
"
height
=
"
37
"
viewBox
=
"
0 0 25 25
"
>
<
g
fill
=
"
none
"
fill
-
rule
=
"
evenodd
"
>
<
path
d
=
"
M20.66 12.693c0-.603-.054-1.182-.155-1.738H12.5v3.287h4.575a3.91 3.91 0 0 1-1.697 2.566v2.133h2.747c1.608-1.48 2.535-3.65 2.535-6.24z
"
fill
=
"
#4285F4
"
/>
<
path
d
=
"
M12.5 21c2.295 0 4.22-.76 5.625-2.06l-2.747-2.132c-.76.51-1.734.81-2.878.81-2.214 0-4.088-1.494-4.756-3.503h-2.84v2.202A8.498 8.498 0 0 0 12.5 21z
"
fill
=
"
#34A853
"
/>
<
path
d
=
"
M7.744 14.115c-.17-.51-.267-1.055-.267-1.615s.097-1.105.267-1.615V8.683h-2.84A8.488 8.488 0 0 0 4 12.5c0 1.372.328 2.67.904 3.817l2.84-2.202z
"
fill
=
"
#FBBC05
"
/>
<
path
d
=
"
M12.5 7.38c1.248 0 2.368.43 3.25 1.272l2.437-2.438C16.715 4.842 14.79 4 12.5 4a8.497 8.497 0 0 0-7.596 4.683l2.84 2.202c.668-2.01 2.542-3.504 4.756-3.504z
"
fill
=
"
#EA4335
"
/>
<
/g
>
<
/svg
>
<
/span
>
<
span
className
=
"
button-label
"
>
Sign
in
with
Google
<
/span
>
<
/div
>
<
/a
>
<
/div
>
<
Login
handleLogin
=
{
handleLogin
}
/
>
)
}
...
...
This diff is collapsed.
Click to expand it.
web-service/client/src/Login.js
0 → 100644
+
27
−
0
View file @
0f24d356
import
React
from
'
react
'
;
const
Login
=
({
handleLogin
})
=>
{
return
(
<
div
style
=
{{
'
padding-top
'
:
'
150px
'
,
'
text-align
'
:
'
center
'
}}
>
<
h2
>
Welcome
to
Future
Technology
Lab
<
/h2>
<
h3
>
Please
login
!<
/h3>
<
a
className
=
"
button
"
onClick
=
{
handleLogin
}
>
<
div
>
<
span
className
=
"
svgIcon t-popup-svg
"
>
<
svg
className
=
"
svgIcon-use
"
width
=
"
25
"
height
=
"
37
"
viewBox
=
"
0 0 25 25
"
>
<
g
fill
=
"
none
"
fill
-
rule
=
"
evenodd
"
>
<
path
d
=
"
M20.66 12.693c0-.603-.054-1.182-.155-1.738H12.5v3.287h4.575a3.91 3.91 0 0 1-1.697 2.566v2.133h2.747c1.608-1.48 2.535-3.65 2.535-6.24z
"
fill
=
"
#4285F4
"
/>
<
path
d
=
"
M12.5 21c2.295 0 4.22-.76 5.625-2.06l-2.747-2.132c-.76.51-1.734.81-2.878.81-2.214 0-4.088-1.494-4.756-3.503h-2.84v2.202A8.498 8.498 0 0 0 12.5 21z
"
fill
=
"
#34A853
"
/>
<
path
d
=
"
M7.744 14.115c-.17-.51-.267-1.055-.267-1.615s.097-1.105.267-1.615V8.683h-2.84A8.488 8.488 0 0 0 4 12.5c0 1.372.328 2.67.904 3.817l2.84-2.202z
"
fill
=
"
#FBBC05
"
/>
<
path
d
=
"
M12.5 7.38c1.248 0 2.368.43 3.25 1.272l2.437-2.438C16.715 4.842 14.79 4 12.5 4a8.497 8.497 0 0 0-7.596 4.683l2.84 2.202c.668-2.01 2.542-3.504 4.756-3.504z
"
fill
=
"
#EA4335
"
/>
<
/g>
<
/svg>
<
/span>
<
span
className
=
"
button-label
"
>
Sign
in
with
Google
<
/span>
<
/div>
<
/a>
<
/div>
)
}
export
default
Login
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
web-service/server/src/index.js
+
2
−
1
View file @
0f24d356
...
...
@@ -5,6 +5,7 @@ const Peer = require('./peer.js');
const
passport
=
require
(
'
passport
'
);
const
passportSetup
=
require
(
'
./passport/passport
'
);
const
jwt
=
require
(
'
jsonwebtoken
'
);
const
keys
=
require
(
'
./passport/keys
'
)
// ---- INDEXES ----------------------------------------------------------------
app
.
use
(
passport
.
initialize
());
...
...
@@ -165,7 +166,7 @@ app.get('/google', passport.authenticate('google', {
*/
app
.
get
(
'
/auth/google/redirect
'
,
passport
.
authenticate
(
'
google
'
),
(
req
,
res
)
=>
{
console
.
log
(
req
.
user
)
const
token
=
jwt
.
sign
(
req
.
user
.
id
,
'
Somesecretkey14madlh£$
'
);
const
token
=
jwt
.
sign
(
req
.
user
.
id
,
keys
.
jwt
.
secret
);
const
htmlWithEmbeddedJWT
=
`
<html>
<body><h3> You will be automatically redirected to next page.<h3><body>
...
...
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