Commit b8ee91b9 authored by thibaut-felten's avatar thibaut-felten

sign up

parent 635a174a
......@@ -3,30 +3,30 @@
<div class="row _centered">
<div class="column _600">
<h1>Inscription</h1>
<form action="post" class="form">
<form action="post" class="form" v-on:submit.prevent="check">
<div class="row lmargin">
<label for="FirstName"> Prénom </label>
<input type="text" name="FirstName" required>
<input v-model="firstname" type="text" name="FirstName" required>
</div>
<div class="row lmargin">
<label for="LastName"> Nom </label>
<input type="text" name="LastName" required>
<input v-model="lastname" type="text" name="LastName" required>
</div>
<div class="row lmargin">
<label for="Login"> Login </label>
<input type="text" name="Login" required>
<input v-model="login" type="text" name="Login" required>
</div>
<div class="row lmargin">
<label for="Email"> Email </label>
<input type="email" name="Email" required>
<input v-model="email" type="email" name="Email" required>
</div>
<div class="row lmargin">
<label for="Password"> Mot de passe </label>
<input type="password" name="Password" required>
<input v-model="password" type="password" name="Password" required>
</div>
<div class="row lmargin">
<label for="ConfirmPassword"> Confirmer MdP </label>
<input type="password" name="ConfirmPassword" required>
<input v-model="confirmpassword" type="password" name="ConfirmPassword" required>
</div>
<div class="row lmargin">
<button type="submit" class="btn"> Valider </button>
......@@ -90,7 +90,53 @@
<script>
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>
......@@ -79,7 +79,6 @@ export default {
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)
......
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