Commit 360cdd5f authored by Robin Borgogno's avatar Robin Borgogno

ajout Game et UserGame au MVC

parents 7a3492af b8ee91b9
...@@ -24,7 +24,7 @@ class LoginController extends Controller { ...@@ -24,7 +24,7 @@ class LoginController extends Controller {
$user = User::tryLogin($json->login); $user = User::tryLogin($json->login);
if(empty($user) || !hash_equals($json->pwd,$user->USER_PASSWORD)) { if(empty($user) || !hash_equals($json->pwd,$user->USER_PASSWORD)) {
$r = new Response(422,"wrong credentials"); $r = new Response(424,"wrong credentials");
$r->send(); $r->send();
} }
......
...@@ -1733,16 +1733,6 @@ ...@@ -1733,16 +1733,6 @@
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true "dev": true
}, },
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"optional": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"cacache": { "cacache": {
"version": "13.0.1", "version": "13.0.1",
"resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz", "resolved": "https://registry.npmjs.org/cacache/-/cacache-13.0.1.tgz",
...@@ -1769,34 +1759,6 @@ ...@@ -1769,34 +1759,6 @@
"unique-filename": "^1.1.1" "unique-filename": "^1.1.1"
} }
}, },
"chalk": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"dev": true,
"optional": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"optional": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"optional": true
},
"find-cache-dir": { "find-cache-dir": {
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz",
...@@ -1818,25 +1780,6 @@ ...@@ -1818,25 +1780,6 @@
"path-exists": "^4.0.0" "path-exists": "^4.0.0"
} }
}, },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"optional": true
},
"loader-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
"dev": true,
"optional": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^2.1.2"
}
},
"locate-path": { "locate-path": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
...@@ -1901,16 +1844,6 @@ ...@@ -1901,16 +1844,6 @@
"minipass": "^3.1.1" "minipass": "^3.1.1"
} }
}, },
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"optional": true,
"requires": {
"has-flag": "^4.0.0"
}
},
"terser-webpack-plugin": { "terser-webpack-plugin": {
"version": "2.3.8", "version": "2.3.8",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz", "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-2.3.8.tgz",
...@@ -1927,18 +1860,6 @@ ...@@ -1927,18 +1860,6 @@
"terser": "^4.6.12", "terser": "^4.6.12",
"webpack-sources": "^1.4.3" "webpack-sources": "^1.4.3"
} }
},
"vue-loader-v16": {
"version": "npm:vue-loader@16.0.0",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0.tgz",
"integrity": "sha512-R20f4PWe34dqhTZ9tkyFd6nfjxEbLBHbFOsN38qg0Jl8GKMfmoyc/E8vVjjRkunE6qCydpPoH7f/tW13bD6+JA==",
"dev": true,
"optional": true,
"requires": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"loader-utils": "^2.0.0"
}
} }
} }
}, },
...@@ -2669,6 +2590,11 @@ ...@@ -2669,6 +2590,11 @@
"tweetnacl": "^0.14.3" "tweetnacl": "^0.14.3"
} }
}, },
"bcryptjs": {
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
"integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms="
},
"bfj": { "bfj": {
"version": "6.1.2", "version": "6.1.2",
"resolved": "https://registry.npmjs.org/bfj/-/bfj-6.1.2.tgz", "resolved": "https://registry.npmjs.org/bfj/-/bfj-6.1.2.tgz",
...@@ -10886,6 +10812,11 @@ ...@@ -10886,6 +10812,11 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"dev": true "dev": true
}, },
"vee-validate": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/vee-validate/-/vee-validate-4.0.2.tgz",
"integrity": "sha512-4NxqfM/oBpCfKlXb4LJFdViBZqRmn5bl5SaaNRDEFNo1IINRT5iugu8OalKcQ2/JsqGYHoVXVtAMhQRqnkmrxw=="
},
"vendors": { "vendors": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.4.tgz", "resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.4.tgz",
...@@ -10975,6 +10906,87 @@ ...@@ -10975,6 +10906,87 @@
} }
} }
}, },
"vue-loader-v16": {
"version": "npm:vue-loader@16.1.0",
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.0.tgz",
"integrity": "sha512-fTtCdI7VeyNK0HP4q4y9Z9ts8TUeaF+2/FjKx8CJ/7/Oem1rCX7zIJe+d+jLrVnVNQjENd3gqmANraLcdRWwnQ==",
"dev": true,
"optional": true,
"requires": {
"chalk": "^4.1.0",
"hash-sum": "^2.0.0",
"loader-utils": "^2.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"optional": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
"integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"dev": true,
"optional": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"optional": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"optional": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"optional": true
},
"loader-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
"integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
"dev": true,
"optional": true,
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^2.1.2"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"optional": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"vue-router": { "vue-router": {
"version": "3.4.9", "version": "3.4.9",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.9.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.9.tgz",
......
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"bcryptjs": "^2.4.3",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"vee-validate": "^4.0.2",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-awesome": "^4.1.0", "vue-awesome": "^4.1.0",
"vue-router": "^3.2.0" "vue-router": "^3.2.0"
......
...@@ -3,30 +3,30 @@ ...@@ -3,30 +3,30 @@
<div class="row _centered"> <div class="row _centered">
<div class="column _600"> <div class="column _600">
<h1>Inscription</h1> <h1>Inscription</h1>
<form action="post" class="form"> <form action="post" class="form" v-on:submit.prevent="check">
<div class="row lmargin"> <div class="row lmargin">
<label for="FirstName"> Prénom </label> <label for="FirstName"> Prénom </label>
<input type="text" name="FirstName" required> <input v-model="firstname" type="text" name="FirstName" required>
</div> </div>
<div class="row lmargin"> <div class="row lmargin">
<label for="LastName"> Nom </label> <label for="LastName"> Nom </label>
<input type="text" name="LastName" required> <input v-model="lastname" type="text" name="LastName" required>
</div> </div>
<div class="row lmargin"> <div class="row lmargin">
<label for="Login"> Login </label> <label for="Login"> Login </label>
<input type="text" name="Login" required> <input v-model="login" type="text" name="Login" required>
</div> </div>
<div class="row lmargin"> <div class="row lmargin">
<label for="Email"> Email </label> <label for="Email"> Email </label>
<input type="email" name="Email" required> <input v-model="email" type="email" name="Email" required>
</div> </div>
<div class="row lmargin"> <div class="row lmargin">
<label for="Password"> Mot de passe </label> <label for="Password"> Mot de passe </label>
<input type="password" name="Password" required> <input v-model="password" type="password" name="Password" required>
</div> </div>
<div class="row lmargin"> <div class="row lmargin">
<label for="ConfirmPassword"> Confirmer MdP </label> <label for="ConfirmPassword"> Confirmer MdP </label>
<input type="password" name="ConfirmPassword" required> <input v-model="confirmpassword" type="password" name="ConfirmPassword" required>
</div> </div>
<div class="row lmargin"> <div class="row lmargin">
<button type="submit" class="btn"> Valider </button> <button type="submit" class="btn"> Valider </button>
...@@ -90,7 +90,53 @@ ...@@ -90,7 +90,53 @@
<script> <script>
export default { export default {
name: 'Inscription' name: 'Inscription',
methods: {
check: function(){
let firstname = this.firstname
let lastname = this.lastname
let login = this.login
let email = this.email
let password = this.password
let confirm = this.confirmpassword
if(confirm !== password){
window.alert("Les mots de passe ne correspondent pas")
return false
}else{
var bcrypt = require('bcryptjs');
var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu"
var hash = bcrypt.hashSync(password, salt)
let data = {
"USER_FIRSTNAME": firstname,
"USER_LASTNAME":lastname,
"USER_LOGIN":login,
"USER_EMAIL":email,
"USER_PASSWORD":hash,
"USER_ROLE":1
}
this.call(data)
}
},
call: function(data){
const url = "http://localhost/projet-cdaw/backend/MVC/api.php/user"
var params = {
method: 'POST',
body : JSON.stringify(data) };
console.log(params.body.lastname)
fetch(url, params)
.then(response=>response.json())
.then(data=>console.log(data))
}
},
} }
</script> </script>
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
<div class="row _centered"> <div class="row _centered">
<div class="column _600"> <div class="column _600">
<h1>Login</h1> <h1>Login</h1>
<form action="/" method="post" class="form"> <form id="loginForm" class="form" v-on:submit.prevent="check">
<div class="row lpad"> <div class="row lpad">
<label for="Login"> Login </label> <label for="Login"> Login </label>
<input type="text" name="Login" required> <input v-model="login" type="text" name="Login" id="loginValue" required>
</div> </div>
<div class="row lpad"> <div class="row lpad">
<label for="Password"> Mot de passe </label> <label for="Password"> Mot de passe </label>
<input type="password" name="Password" required> <input v-model="password" type="password" name="Password" id="passwordValue" required>
</div> </div>
<div class="row lpad"> <div class="row lpad">
<button type="submit" class="btn"> Valider </button> <button type="submit" class="btn"> Valider </button>
...@@ -74,7 +74,40 @@ ...@@ -74,7 +74,40 @@
<script> <script>
export default { export default {
name: 'Login' name: 'Login',
} methods: {
check: function(){
let login = this.login
let password = this.password
var bcrypt = require('bcryptjs');
var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu"
var hash = bcrypt.hashSync(password, salt)
this.call(login, hash)
},
call: function(login, password){
const url = "http://localhost/projet-cdaw/backend/MVC/api.php/login"
let data = {
login: login,
pwd: password
}
console.log(JSON.stringify(data))
var params = {
method: 'POST',
body : JSON.stringify(data) };
fetch(url, params)
.then(response=>response.json())
.then(data=>console.log(data))
}
},
}
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment