Skip to content

Commit 9471093

Browse files
committed
Add csrf component
1 parent 598bae7 commit 9471093

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

resources/assets/pterodactyl/scripts/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ let token = document.head.querySelector('meta[name="csrf-token"]');
3030

3131
if (token) {
3232
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
33+
window.X_CSRF_TOKEN = token.content;
3334
} else {
3435
console.error('CSRF token not found in document.');
3536
}

resources/assets/pterodactyl/scripts/components/auth/ForgotPassword.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</div>
1313
</div>
1414
<div>
15+
<csrf/>
1516
<button class="btn btn-blue btn-jumbo" type="submit">
1617
{{ $t('auth.recover_account') }}
1718
</button>
@@ -26,11 +27,19 @@
2627
</template>
2728

2829
<script>
30+
import Csrf from "../shared/CSRF";
31+
2932
export default {
33+
components: {Csrf},
3034
name: 'forgot-password',
3135
props: {
3236
email: {type: String, required: true},
3337
},
38+
data: function () {
39+
return {
40+
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
41+
};
42+
},
3443
methods: {
3544
updateEmail: function (event) {
3645
this.$emit('update-email', event.target.value);

resources/assets/pterodactyl/scripts/components/auth/LoginForm.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</div>
1818
</div>
1919
<div>
20+
<csrf/>
2021
<button class="btn btn-blue btn-jumbo" type="submit">
2122
{{ $t('auth.sign_in') }}
2223
</button>
@@ -31,11 +32,19 @@
3132
</template>
3233

3334
<script>
35+
import Csrf from "../shared/CSRF";
36+
3437
export default {
38+
components: {Csrf},
3539
name: 'login-form',
3640
props: {
3741
email: { type: String, required: true },
3842
},
43+
data: function () {
44+
return {
45+
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
46+
};
47+
},
3948
methods: {
4049
updateEmail: function (event) {
4150
this.$emit('update-email', event.target.value);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<template>
2+
<input type="hidden" name="_token" v-bind:value="X_CSRF_TOKEN" />
3+
</template>
4+
5+
<script>
6+
export default {
7+
name: 'csrf',
8+
data: function () {
9+
return {
10+
X_CSRF_TOKEN: window.X_CSRF_TOKEN,
11+
};
12+
},
13+
}
14+
</script>

0 commit comments

Comments
 (0)