This commit is contained in:
Timo Volkmann 2019-05-07 13:19:11 +02:00
parent c0845f835f
commit 3c884dcd90
2 changed files with 56 additions and 66 deletions

View File

@ -73,17 +73,9 @@
user: {
email: "",
password: "",
//token: "",
// evalAuthentication: false
},
};
},
// beforeMount: {
// init: function () {
// this.evalAuthentication();
// console.log("initiated");
// }
// },
created() {
this.evalAuthentication();
console.log("created: initiated");

View File

@ -6,58 +6,54 @@
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.name" type="text"
label="Nutzername" :rules="[val=>val.length>=2||'Name muss mindestens 2 Zeichen lang sein!']"/>
<q-input lazy-rules outlined filled stack-label v-model="user.email" type="text" label="E-Mail"
:rules="[val=>validateEmail(val)||'Bitte gültige E-Mail angeben!']"/>
</div>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.email" type="text" label="E-Mail" :rules="[val=>validateEmail(val)||'Bitte gültige E-Mail angeben!']"/>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.checkemail" type="text"
label="E-Mail erneut eingeben" placeholer="Email"
:rules="[val=>val===user.email||'E-Mail stimmt nicht überein!']"/>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.checkemail" type="text"
label="E-Mail erneut eingeben" placeholer="Email" :rules="[val=>val===user.email||'E-Mail stimmt nicht überein!']"/>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.password" type="password"
label="Passwort"
:rules="[val=>val.length>=8||'Passwort muss mindestens 8 Zeichen lang sein!']"/>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.password" type="password"
label="Passwort" :rules="[val=>val.length>=8||'Passwort muss mindestens 8 Zeichen lang sein!']"/>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.checkpassword" type="password"
label="Passwort erneut eingeben"
:rules="[val=>val===user.password||'Passwort stimmt nicht überein']"/>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-input lazy-rules outlined filled stack-label v-model="user.checkpassword" type="password"
label="Passwort erneut eingeben" :rules="[val=>val===user.password||'Passwort stimmt nicht überein']"/>
</div>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-btn
:disabled="!validationSuccesful"
label="Registrieren"
color="primary"
class="full-width"
@click="register()"
unelevated
/>
</div>
</div>
<div class="col">
<div class="">
<div class="" style="max-width: 440px">
<q-btn
:disabled="!validationSuccesful"
label="Registrieren"
color="primary"
class="full-width"
@click="register()"
unelevated
/>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</template>
@ -65,23 +61,21 @@
<script>
export default {
data() {
return{
return {
user: {
name:"",
email:"",
checkemail:"",
email: "",
checkemail: "",
password: "",
checkpassword: "",
},
}
},
computed: {
validationSuccesful(){
if(this.user.name.length>=2
&&this.validateEmail(this.user.email)
&&this.user.email===this.user.checkemail
&&this.user.password.length>=8
&&this.user.password===this.user.checkpassword){
validationSuccesful() {
if (this.validateEmail(this.user.email)
&& this.user.email === this.user.checkemail
&& this.user.password.length >= 8
&& this.user.password === this.user.checkpassword) {
return true;
}
return false;
@ -97,9 +91,9 @@
},
register: function () {
if(this.user.email===this.user.checkemail&&this.user.password===this.user.checkpassword){
if (this.user.email === this.user.checkemail && this.user.password === this.user.checkpassword) {
const data = {
name: this.user.name,
name: this.user.email,
password: this.user.password,
email: this.user.email,
roles: [
@ -112,15 +106,19 @@
console.log("POST /api/register/ - json: " + JSON.stringify(data));
const token = JSON.parse(localStorage.getItem('registerToken')).token;
this.$axios.post(process.env.USER_API+'/account/register', data,{
this.$axios.post(process.env.USER_API + '/account/register', data, {
headers: {
'Authorization': 'Bearer ' + token,
}
})
.then((response) => {
console.log(response.data);
if(response.status === 201){
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: "Deine Registrierung war erfolgreich! Du kannst dich jetzt einloggen.", title: "Registrierungsprozess", color: "blue"});
if (response.status === 201) {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Deine Registrierung war erfolgreich! Du kannst dich jetzt einloggen.",
title: "Registrierungsprozess",
color: "blue"
});
this.$router.push("/login")
}
})
@ -148,12 +146,12 @@
})
} else {
if(this.user.email!=this.user.checkemail) {
if (this.user.email != this.user.checkemail) {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Email stimmt nicht überein",
title: "Fehler",
});
} else if (this.user.password!=this.user.checkpassword){
} else if (this.user.password != this.user.checkpassword) {
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {
message: "Passwort stimmt nicht überein",
title: "Fehler",
@ -170,7 +168,7 @@
console.log("GET /api/login/ - json: " + JSON.stringify(logindata));
this.$axios.post(process.env.USER_API+'/account/login', logindata)
this.$axios.post(process.env.USER_API + '/account/login', logindata)
.then((response) => {
localStorage.setItem('registerToken', JSON.stringify(response.data));
})
@ -194,7 +192,7 @@
message = error.message;
}
console.log(error.config);
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: message, title: header,});
})
},
},