Add custom flash library that works as expected
This commit is contained in:
parent
bab20812a0
commit
0a706d1b45
13 changed files with 233 additions and 37 deletions
|
@ -1,12 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="pb-4" v-for="error in errors">
|
||||
<div class="p-2 bg-red-dark border-red-darker border items-center text-red-lightest leading-normal rounded flex lg:inline-flex w-full text-sm"
|
||||
role="alert">
|
||||
<span class="flex rounded-full bg-red uppercase px-2 py-1 text-xs font-bold mr-3 leading-none">Error</span>
|
||||
<span class="mr-2 text-left flex-auto">{{ error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<form class="bg-white shadow-lg rounded-lg pt-10 px-8 pb-6 mb-4 animate fadein" method="post"
|
||||
v-on:submit.prevent="submitForm"
|
||||
>
|
||||
|
@ -70,13 +63,14 @@
|
|||
this.$data.showSpinner = true;
|
||||
this.$data.errors = [];
|
||||
|
||||
this.clearFlashes();
|
||||
window.axios.post(this.route('auth.forgot-password'), {
|
||||
email: this.$props.email,
|
||||
})
|
||||
.then(function (response) {
|
||||
self.$data.submitDisabled = false;
|
||||
self.$data.showSpinner = false;
|
||||
self.flash({message: response.data.status, variant: 'success'});
|
||||
self.success(response.data.status);
|
||||
self.$router.push({name: 'login'});
|
||||
})
|
||||
.catch(function (err) {
|
||||
|
@ -87,7 +81,9 @@
|
|||
|
||||
const response = err.response;
|
||||
if (response.data && _.isObject(response.data.errors)) {
|
||||
self.$data.errors.push(response.data.errors[0].detail);
|
||||
response.data.errors.forEach(function (error) {
|
||||
self.error(error.detail);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<flash/>
|
||||
<login-form
|
||||
v-if="this.$route.name === 'login'"
|
||||
v-bind:user="user"
|
||||
|
@ -15,8 +16,9 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import LoginForm from "./LoginForm";
|
||||
import Flash from '../Flash';
|
||||
import ForgotPassword from "./ForgotPassword";
|
||||
import LoginForm from "./LoginForm";
|
||||
import TwoFactorForm from "./TwoFactorForm";
|
||||
|
||||
export default {
|
||||
|
@ -34,6 +36,7 @@
|
|||
},
|
||||
},
|
||||
components: {
|
||||
Flash,
|
||||
TwoFactorForm,
|
||||
ForgotPassword,
|
||||
LoginForm,
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<flash-message variant="danger" />
|
||||
<flash-message variant="success" />
|
||||
<div class="pb-4" v-for="error in errors">
|
||||
<div class="p-2 bg-red-dark border-red-darker border items-center text-red-lightest leading-normal rounded flex lg:inline-flex w-full text-sm"
|
||||
role="alert">
|
||||
<span class="flex rounded-full bg-red uppercase px-2 py-1 text-xs font-bold mr-3 leading-none">Error</span>
|
||||
<span class="mr-2 text-left flex-auto">{{ error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<form class="bg-white shadow-lg rounded-lg pt-10 px-8 pb-6 mb-4 animate fadein" method="post"
|
||||
v-on:submit.prevent="submitForm"
|
||||
>
|
||||
|
@ -84,6 +75,7 @@
|
|||
const self = this;
|
||||
this.$data.showSpinner = true;
|
||||
|
||||
this.clearFlashes();
|
||||
axios.post(this.route('auth.login'), {
|
||||
user: this.$props.user.email,
|
||||
password: this.$props.user.password,
|
||||
|
@ -106,7 +98,9 @@
|
|||
|
||||
const response = err.response;
|
||||
if (response.data && _.isObject(response.data.errors)) {
|
||||
self.$data.errors = [response.data.errors[0].detail];
|
||||
response.data.errors.forEach(function (error) {
|
||||
self.error(error.detail);
|
||||
});
|
||||
self.$refs.password.focus();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="pb-4" v-for="error in errors">
|
||||
<div class="p-2 bg-red-dark border-red-darker border items-center text-red-lightest leading-normal rounded flex lg:inline-flex w-full text-sm"
|
||||
role="alert">
|
||||
<span class="flex rounded-full bg-red uppercase px-2 py-1 text-xs font-bold mr-3 leading-none">Error</span>
|
||||
<span class="mr-2 text-left flex-auto">{{ error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<form class="bg-white shadow-lg rounded-lg pt-10 px-8 pb-6 mb-4 animate fadein" method="post"
|
||||
v-on:submit.prevent="submitForm"
|
||||
>
|
||||
|
@ -90,6 +83,7 @@
|
|||
const self = this;
|
||||
this.$data.showSpinner = true;
|
||||
|
||||
this.clearFlashes();
|
||||
window.axios.post(this.route('auth.reset-password'), {
|
||||
email: this.$props.email,
|
||||
password: this.$data.password,
|
||||
|
@ -107,7 +101,9 @@
|
|||
|
||||
const response = err.response;
|
||||
if (response.data && _.isObject(response.data.errors)) {
|
||||
self.$data.errors = [response.data.errors[0].detail];
|
||||
response.data.errors.forEach(function (error) {
|
||||
self.error(error.detail);
|
||||
});
|
||||
self.$refs.password.focus();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
submitToken: function () {
|
||||
const self = this;
|
||||
|
||||
self.clearFlashes();
|
||||
axios.post(this.route('auth.login-checkpoint'), {
|
||||
confirmation_token: this.$route.query.token,
|
||||
authentication_code: this.$data.code,
|
||||
|
@ -57,7 +58,9 @@
|
|||
|
||||
const response = err.response;
|
||||
if (response.data && _.isObject(response.data.errors)) {
|
||||
self.flash({message: response.data.errors[0].detail, variant: 'danger'});
|
||||
response.data.errors.forEach(function (error) {
|
||||
self.error(error.detail);
|
||||
});
|
||||
self.$router.push({ name: 'login' });
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue