Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-cdaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
Thibaut Felten
projet-cdaw
Commits
8f9e8061
Commit
8f9e8061
authored
Dec 01, 2020
by
Robin Borgogno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajout var user
parent
524a663b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
37 deletions
+50
-37
LoginController.class.php
backend/MVC/controller/LoginController.class.php
+2
-1
user.js
frontend/src/model/user.js
+26
-20
AdminPrivate.vue
frontend/src/views/AdminPrivate.vue
+8
-2
Login.vue
frontend/src/views/Login.vue
+14
-14
No files found.
backend/MVC/controller/LoginController.class.php
View file @
8f9e8061
...
@@ -47,7 +47,8 @@ class LoginController extends Controller {
...
@@ -47,7 +47,8 @@ class LoginController extends Controller {
$jwt
=
JWT
::
encode
(
$token
,
JWT_BACKEND_KEY
);
$jwt
=
JWT
::
encode
(
$token
,
JWT_BACKEND_KEY
);
$jsonResult
=
json_encode
(
$jsonResult
=
json_encode
(
array
(
array
(
"jwt_token"
=>
$jwt
"jwt_token"
=>
$jwt
,
"data"
=>
$token
[
'data'
]
)
)
);
);
...
...
frontend/src/model/user.js
View file @
8f9e8061
export
default
class
user
{
//
export default class user {
token
=
""
;
//
token = "";
id
=
0
;
//
id = 0;
putId
(
id
)
//
putId(id)
{
//
{
this
.
id
=
id
//
this.id = id
}
//
}
getId
()
//
getId()
{
//
{
return
this
.
id
//
return this.id
}
//
}
putToken
(
token
)
//
putToken(token)
{
//
{
this
.
token
=
token
//
this.token = token
}
//
}
getToken
()
//
getToken()
{
//
{
return
this
.
token
//
return this.token
}
//
}
}
// }
\ No newline at end of file
let
user
=
{
token
:
""
,
id
:
0
}
module
.
exports
=
user
\ No newline at end of file
frontend/src/views/AdminPrivate.vue
View file @
8f9e8061
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
<div
class=
"row _centered"
>
<div
class=
"row _centered"
>
<div
class=
"column _600"
>
<div
class=
"column _600"
>
<div
class=
"codeGame"
>
<div
class=
"codeGame"
>
<h1
class=
"titre"
>
Code de la partie :
</h1>
<h1
class=
"titre"
>
Code de la partie :
{{
returnID
()
}}
</h1>
<h1
class=
"titre"
id=
"codeGame"
>
{{
idGame
()
}}
</h1>
<h1
class=
"titre"
id=
"codeGame"
>
{{
idGame
()
}}
{{
returnID
()
}}
</h1>
</div>
</div>
<div
class=
"joueurs"
>
<div
class=
"joueurs"
>
<!-- ajoute les joueurs présent -->
<!-- ajoute les joueurs présent -->
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
</
style
>
</
style
>
<
script
>
<
script
>
const
user
=
require
(
"../model/user.js"
)
export
default
{
export
default
{
name
:
'AdminPrivate'
,
name
:
'AdminPrivate'
,
methods
:
{
methods
:
{
...
@@ -41,6 +42,8 @@ export default {
...
@@ -41,6 +42,8 @@ export default {
var
params
=
{
var
params
=
{
method
:
'POST'
,
method
:
'POST'
,
body
:
JSON
.
stringify
(
data
)
};
body
:
JSON
.
stringify
(
data
)
};
console
.
log
(
user
)
fetch
(
url
,
params
)
fetch
(
url
,
params
)
.
then
(
response
=>
response
.
json
())
.
then
(
response
=>
response
.
json
())
...
@@ -48,6 +51,9 @@ export default {
...
@@ -48,6 +51,9 @@ export default {
document
.
getElementById
(
"codeGame"
).
innerHTML
=
data
[
0
].
id
document
.
getElementById
(
"codeGame"
).
innerHTML
=
data
[
0
].
id
})
})
},
},
returnID
:
function
(){
return
user
.
id
}
},
},
}
}
</
script
>
</
script
>
\ No newline at end of file
frontend/src/views/Login.vue
View file @
8f9e8061
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
</
style
>
</
style
>
<
script
>
<
script
>
const
user
=
require
(
"../model/user.js"
)
export
default
{
export
default
{
name
:
'Login'
,
name
:
'Login'
,
...
@@ -82,10 +82,10 @@ export default {
...
@@ -82,10 +82,10 @@ export default {
check
:
function
(){
check
:
function
(){
let
login
=
this
.
login
let
login
=
this
.
login
let
password
=
this
.
password
let
password
=
this
.
password
var
bcrypt
=
require
(
'bcryptjs'
);
//
var bcrypt = require('bcryptjs');
var
salt
=
"$2a$08$c0GzKSB8g6.rZLF98GJvQu"
//
var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu"
var
hash
=
bcrypt
.
hashSync
(
password
,
salt
)
//
var hash = bcrypt.hashSync(password, salt)
this
.
call
(
login
,
hash
)
this
.
call
(
login
,
password
)
},
},
call
:
function
(
login
,
password
){
call
:
function
(
login
,
password
){
...
@@ -99,23 +99,23 @@ export default {
...
@@ -99,23 +99,23 @@ export default {
var
params
=
{
var
params
=
{
method
:
'POST'
,
method
:
'POST'
,
body
:
JSON
.
stringify
(
data
)
};
body
:
JSON
.
stringify
(
data
)
};
fetch
(
url
,
params
)
fetch
(
url
,
params
)
.
then
(
response
=>
response
.
json
())
.
then
(
response
=>
response
.
json
())
.
then
(
response
=>
{
.
then
(
response
=>
{
sessionStorage
.
setItem
(
"JWT_TOKEN"
,
response
.
data
.
jwt_token
)
sessionStorage
.
setItem
(
"JWT_TOKEN"
,
response
.
data
.
jwt_token
)
console
.
log
(
sessionStorage
.
getItem
(
"JWT_TOKEN"
))
user
.
token
=
response
.
jwt_token
user
.
id
=
response
.
data
.
id
console
.
log
(
response
)
})
})
}
}
},
},
components
:
{
components
:
{
LoginNavbar
LoginNavbar
},
},
}
}
import
LoginNavbar
from
'../components/LoginNavbar.vue'
import
LoginNavbar
from
'../components/LoginNavbar.vue'
</
script
>
</
script
>
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