Add csrf component
This commit is contained in:
parent
598bae7b70
commit
94710934b9
|
@ -30,6 +30,7 @@ let token = document.head.querySelector('meta[name="csrf-token"]');
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
||||||
|
window.X_CSRF_TOKEN = token.content;
|
||||||
} else {
|
} else {
|
||||||
console.error('CSRF token not found in document.');
|
console.error('CSRF token not found in document.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<csrf/>
|
||||||
<button class="btn btn-blue btn-jumbo" type="submit">
|
<button class="btn btn-blue btn-jumbo" type="submit">
|
||||||
{{ $t('auth.recover_account') }}
|
{{ $t('auth.recover_account') }}
|
||||||
</button>
|
</button>
|
||||||
|
@ -26,11 +27,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Csrf from "../shared/CSRF";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {Csrf},
|
||||||
name: 'forgot-password',
|
name: 'forgot-password',
|
||||||
props: {
|
props: {
|
||||||
email: {type: String, required: true},
|
email: {type: String, required: true},
|
||||||
},
|
},
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateEmail: function (event) {
|
updateEmail: function (event) {
|
||||||
this.$emit('update-email', event.target.value);
|
this.$emit('update-email', event.target.value);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<csrf/>
|
||||||
<button class="btn btn-blue btn-jumbo" type="submit">
|
<button class="btn btn-blue btn-jumbo" type="submit">
|
||||||
{{ $t('auth.sign_in') }}
|
{{ $t('auth.sign_in') }}
|
||||||
</button>
|
</button>
|
||||||
|
@ -31,11 +32,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Csrf from "../shared/CSRF";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {Csrf},
|
||||||
name: 'login-form',
|
name: 'login-form',
|
||||||
props: {
|
props: {
|
||||||
email: { type: String, required: true },
|
email: { type: String, required: true },
|
||||||
},
|
},
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
|
||||||
|
};
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateEmail: function (event) {
|
updateEmail: function (event) {
|
||||||
this.$emit('update-email', event.target.value);
|
this.$emit('update-email', event.target.value);
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<template>
|
||||||
|
<input type="hidden" name="_token" v-bind:value="X_CSRF_TOKEN" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'csrf',
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue