Skip to content

Commit 6b2649a

Browse files
committed
Merge branch 'feature/vuejs' into feature/vuejs-serverlist
2 parents cf07ba5 + 6005def commit 6b2649a

File tree

18 files changed

+482
-12
lines changed

18 files changed

+482
-12
lines changed

.env.dusk

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
APP_ENV=local
2+
APP_DEBUG=false
3+
APP_KEY=NDWgIKKi9ovNK1PXZpzfNVSBdfCXGb5i
4+
APP_JWT_KEY=test1234
5+
APP_TIMEZONE=America/Los_Angeles
6+
APP_URL=http://pterodactyl.local
7+
8+
CACHE_DRIVER=file
9+
SESSION_DRIVER=file
10+
11+
HASHIDS_SALT=IqRr0g82tCTeuyxGs8RV
12+
HASHIDS_LENGTH=8
13+
14+
MAIL_DRIVER=log
15+
MAIL_FROM=support@pterodactyl.io
16+
QUEUE_DRIVER=array
17+
18+
APP_SERVICE_AUTHOR=testing@pterodactyl.io
19+
MAIL_FROM_NAME="Pterodactyl Panel"
20+
RECAPTCHA_ENABLED=false
21+
22+
DB_CONNECTION=testing
23+
TESTING_DB_HOST=services.pterodactyl.local
24+
TESTING_DB_DATABASE=panel_test
25+
TESTING_DB_USERNAME=panel_test
26+
TESTING_DB_PASSWORD=Test1234

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"filp/whoops": "^2.1",
4949
"friendsofphp/php-cs-fixer": "^2.11.1",
5050
"fzaninotto/faker": "^1.6",
51+
"laravel/dusk": "^3.0",
5152
"martinlindhe/laravel-vue-i18n-generator": "^0.1.28",
5253
"mockery/mockery": "^1.0",
5354
"nunomaduro/collision": "^2.0",
@@ -68,6 +69,7 @@
6869
},
6970
"autoload-dev": {
7071
"psr-4": {
72+
"Pterodactyl\\Tests\\Browser\\": "tests/Browser",
7173
"Pterodactyl\\Tests\\Integration\\": "tests/Integration",
7274
"Tests\\": "tests/"
7375
}

composer.lock

Lines changed: 122 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
processIsolation="false"
1111
stopOnFailure="false">
1212
<testsuites>
13+
<testsuite name="Browser">
14+
<directory suffix="Test.php">./tests/Browser/Processes</directory>
15+
</testsuite>
1316
<testsuite name="Integration">
1417
<directory suffix="Test.php">./tests/Integration</directory>
1518
</testsuite>

resources/assets/scripts/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ try {
1717
*/
1818

1919
window.axios = require('axios');
20-
2120
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
21+
window.axios.defaults.headers.common['Accept'] = 'application/json';
2222
window.axios.defaults.headers.common['Authorization'] = 'Bearer ' + localStorage.token || '';
2323

2424
if (typeof phpdebugbar !== 'undefined') {

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
>
66
<div class="flex flex-wrap -mx-3 mb-6">
77
<div class="input-open">
8-
<input class="input" id="grid-email" type="email" aria-labelledby="grid-email" ref="email" required
8+
<input class="input" id="grid-email" type="email" aria-labelledby="grid-email-label" required
9+
ref="email"
910
v-bind:class="{ 'has-content': email.length > 0 }"
1011
v-bind:readonly="showSpinner"
1112
v-bind:value="email"
1213
v-on:input="updateEmail($event)"
1314
/>
14-
<label for="grid-email">{{ $t('strings.email') }}</label>
15+
<label for="grid-email" id="grid-email-label">{{ $t('strings.email') }}</label>
1516
<p class="text-grey-darker text-xs">{{ $t('auth.forgot_password.label_help') }}</p>
1617
</div>
1718
</div>
@@ -25,6 +26,7 @@
2526
</div>
2627
<div class="pt-6 text-center">
2728
<router-link class="text-xs text-grey tracking-wide no-underline uppercase hover:text-grey-dark"
29+
aria-label="Go to login"
2830
:to="{ name: 'login' }"
2931
>
3032
{{ $t('auth.go_to_login') }}
@@ -68,6 +70,10 @@
6870
email: this.$props.email,
6971
})
7072
.then(function (response) {
73+
if (!(response.data instanceof Object)) {
74+
throw new Error('An error was encountered while processing this request.');
75+
}
76+
7177
self.$data.submitDisabled = false;
7278
self.$data.showSpinner = false;
7379
self.success(response.data.status);

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,38 @@
55
>
66
<div class="flex flex-wrap -mx-3 mb-6">
77
<div class="input-open">
8-
<input class="input" id="grid-username" type="text" name="user" aria-labelledby="grid-username" required
8+
<input class="input" id="grid-username" type="text" name="user" aria-labelledby="grid-username-label" required
99
ref="email"
1010
:class="{ 'has-content' : user.email.length > 0 }"
1111
:readonly="showSpinner"
1212
:value="user.email"
1313
v-on:input="updateEmail($event)"
1414
/>
15-
<label for="grid-username">{{ $t('strings.user_identifier') }}</label>
15+
<label id="grid-username-label" for="grid-username">{{ $t('strings.user_identifier') }}</label>
1616
</div>
1717
</div>
1818
<div class="flex flex-wrap -mx-3 mb-6">
1919
<div class="input-open">
20-
<input class="input" id="grid-password" type="password" name="password" aria-labelledby="grid-password" required
20+
<input class="input" id="grid-password" type="password" name="password" aria-labelledby="grid-password-label" required
2121
ref="password"
2222
:class="{ 'has-content' : user.password && user.password.length > 0 }"
2323
:readonly="showSpinner"
2424
v-model="user.password"
2525
/>
26-
<label for="grid-password">{{ $t('strings.password') }}</label>
26+
<label id="grid-password-label" for="grid-password">{{ $t('strings.password') }}</label>
2727
</div>
2828
</div>
2929
<div>
30-
<button class="btn btn-blue btn-jumbo" type="submit" v-bind:disabled="showSpinner">
30+
<button id="grid-login-button" class="btn btn-blue btn-jumbo" type="submit" aria-label="Log in"
31+
v-bind:disabled="showSpinner">
3132
<span class="spinner white" v-bind:class="{ hidden: ! showSpinner }">&nbsp;</span>
3233
<span v-bind:class="{ hidden: showSpinner }">
3334
{{ $t('auth.sign_in') }}
3435
</span>
3536
</button>
3637
</div>
3738
<div class="pt-6 text-center">
38-
<router-link class="text-xs text-grey tracking-wide no-underline uppercase hover:text-grey-dark"
39+
<router-link class="text-xs text-grey tracking-wide no-underline uppercase hover:text-grey-dark" aria-label="Forgot password"
3940
:to="{ name: 'forgot-password' }">
4041
{{ $t('auth.forgot_password.label') }}
4142
</router-link>
@@ -81,6 +82,12 @@
8182
password: this.$props.user.password,
8283
})
8384
.then(function (response) {
85+
// If there is a 302 redirect or some other odd behavior (basically, response that isnt
86+
// in JSON format) throw an error and don't try to continue with the login.
87+
if (!(response.data instanceof Object)) {
88+
throw new Error('An error was encountered while processing this request.');
89+
}
90+
8491
if (response.data.complete) {
8592
localStorage.setItem('token', response.data.token);
8693
self.$store.dispatch('login');
@@ -94,6 +101,7 @@
94101
.catch(function (err) {
95102
self.$props.user.password = '';
96103
self.$data.showSpinner = false;
104+
self.$refs.password.focus();
97105
self.$store.dispatch('logout');
98106
99107
if (!err.response) {
@@ -105,7 +113,6 @@
105113
response.data.errors.forEach(function (error) {
106114
self.error(error.detail);
107115
});
108-
self.$refs.password.focus();
109116
}
110117
});
111118
},

resources/assets/scripts/components/auth/ResetPassword.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
token: this.$props.token,
9494
})
9595
.then(function (response) {
96+
if (!(response.data instanceof Object)) {
97+
throw new Error('An error was encountered while processing this login.');
98+
}
99+
96100
return window.location = response.data.redirect_to;
97101
})
98102
.catch(function (err) {

resources/assets/scripts/components/auth/TwoFactorForm.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
};
3838
},
3939
mounted: function () {
40+
if ((this.$route.query.token || '').length < 1) {
41+
return this.$router.push({ name: 'login' });
42+
}
43+
4044
this.$refs.code.focus();
4145
},
4246
methods: {
@@ -49,8 +53,13 @@
4953
authentication_code: this.$data.code,
5054
})
5155
.then(function (response) {
56+
if (!(response.data instanceof Object)) {
57+
throw new Error('An error was encountered while processing this login.');
58+
}
59+
5260
localStorage.setItem('token', response.data.token);
5361
self.$store.dispatch('login');
62+
5463
window.location = response.data.intended;
5564
})
5665
.catch(function (err) {

resources/assets/scripts/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ResetPassword from './components/auth/ResetPassword';
77
export const routes = [
88
{ name: 'login', path: '/auth/login', component: Login },
99
{ name: 'forgot-password', path: '/auth/password', component: Login },
10-
{ name: 'checkpoint', path: '/checkpoint', component: Login },
10+
{ name: 'checkpoint', path: '/auth/checkpoint', component: Login },
1111
{
1212
name: 'reset-password',
1313
path: '/auth/password/reset/:token',

0 commit comments

Comments
 (0)