login, profile edit

This commit is contained in:
scammo
2021-06-24 00:40:27 +02:00
parent ffc335f935
commit 356aa738fb
2 changed files with 139 additions and 42 deletions

View File

@ -3,14 +3,14 @@
<h1>Kompetenz Inventar by WTF eG</h1>
<form @submit.prevent="submitLogin()">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label"
<label for="exampleInputusername1" class="form-label"
>E-Mail Aresse:
</label>
<input
type="email"
type="username"
class="form-control"
id="exampleInputEmail1"
v-model="email"
id="exampleInputusername1"
v-model="username"
required
/>
</div>
@ -27,8 +27,13 @@
<button type="submit" class="btn btn-primary mb-4">Login</button>
</form>
<a href="https://resetpw.wtf-eg.de/">Globales WTF Passwort zurücksetzen</a>
<div class="alert alert-danger mb-4 mt-4" role="alert" v-if="showErrorMessage">
Mit deinen Login Daten ist ein Fehler aufgetreten. Versuch es nochmal oder <a href="https://resetpw.wtf-eg.de/">erzeuge ein neues Passwort</a>.
<div
class="alert alert-danger mb-4 mt-4"
role="alert"
v-if="showErrorMessage"
>
Mit deinen Login Daten ist ein Fehler aufgetreten. Versuch es nochmal oder
<a href="https://resetpw.wtf-eg.de/">erzeuge ein neues Passwort</a>.
</div>
<p>
Das Login gilt nur für WTF eG Mitglieder. Du kannst dein Ldap Passwort
@ -37,40 +42,42 @@
</div>
</template>
<script>
import axios from 'axios'
import axios from "axios";
export default {
name: "Index",
data(){
return {
showErrorMessage: false,
email: '',
password: ''
}
data() {
return {
showErrorMessage: false,
username: "",
password: "",
};
},
methods: {
async submitLogin(){
this.showErrorMessage = false
try{
const loginResult = await axios.post(
`${process.env.VUE_APP_API_URL}/users/login`,
{
email: this.email,
password: this.password
})
if(loginResult.status === 200){
//success login
this.router.push({path: 's/search'})
}
else{
this.showErrorMessage = true
}
}catch(error){
console.error()
this.showErrorMessage = true
async submitLogin() {
this.showErrorMessage = false;
try {
const loginResult = await axios.post(
`${process.env.VUE_APP_API_URL}/users/login`,
{
username: this.username,
password: this.password,
}
);
console.log(loginResult);
if (loginResult.status === 200) {
//success login
localStorage.setItem("token", loginResult.token);
localStorage.setItem("user_id", loginResult.user_id);
this.router.push({ path: "s/search" });
} else {
this.showErrorMessage = true;
}
} catch (error) {
console.error();
this.showErrorMessage = true;
}
}
}
},
},
};
</script>