Skip to content

Commit 5e570da

Browse files
committed
Update to vue-auth (@websanova) v.3
1 parent 1996489 commit 5e570da

File tree

6 files changed

+31
-46
lines changed

6 files changed

+31
-46
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"devDependencies": {},
1313
"dependencies": {
1414
"@fortawesome/fontawesome-free": "5.14.0",
15-
"@websanova/vue-auth": "^2.21.14-beta",
15+
"@websanova/vue-auth": "3.3.1",
1616
"axios": "^0.19.2",
1717
"bootstrap": "4.5.2",
1818
"cross-env": "^7.0.2",

resources/js/bootstrap/auth.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ axios.interceptors.response.use(response => response, error => {
2525
})
2626

2727
Vue.use(VueAuth, {
28-
auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
29-
http: require('@websanova/vue-auth/drivers/http/axios.1.x.js'),
30-
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
31-
loginData: { url: process.env.MIX_API_ENDPOINT + 'auth/login' },
32-
logoutData: { url: process.env.MIX_API_ENDPOINT + 'auth/logout', redirect: '/login' },
33-
registerData: { url: process.env.MIX_API_ENDPOINT + 'auth/register', method: 'POST'},
28+
auth: require('@websanova/vue-auth/dist/drivers/auth/bearer.js'),
29+
http: require('@websanova/vue-auth/dist/drivers/http/axios.1.x.js'),
30+
router: require('@websanova/vue-auth/dist/drivers/router/vue-router.2.x.js'),
31+
loginData: { url: process.env.MIX_API_ENDPOINT + 'auth/login', redirect: '/admin/' },
32+
logoutData: { url: process.env.MIX_API_ENDPOINT + 'auth/logout', redirect: '/login', makeRequest: true },
33+
registerData: { url: process.env.MIX_API_ENDPOINT + 'auth/register', method: 'POST', redirect: '/login' },
3434
fetchData: { url: process.env.MIX_API_ENDPOINT + 'auth/me', method: 'POST' },
3535
refreshData: { enabled: false },
3636
});

resources/js/modules/auth/components/Login.vue

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@
1818
},
1919
methods: {
2020
onSubmit(loginData) {
21-
const self = this;
22-
this.$auth.login({
23-
data: loginData,
24-
redirect: {name: 'Dashboard'},
25-
success: response => {
26-
self.loading = false;
27-
},
28-
error: error => {
21+
this.loading = true
22+
this.$auth
23+
.login({
24+
data: loginData,
25+
})
26+
.then(() => {
27+
// success
28+
}, error => {
2929
if (error.response.status === 422)
3030
this.authErrors = error.response.data.errors
31-
self.loading = false;
32-
},
33-
})
31+
})
32+
.finally(() => this.loading = false);
3433
}
3534
}
3635
}

resources/js/modules/auth/components/Register.vue

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,22 @@
2020
},
2121
methods: {
2222
onSubmit(signUpFormData) {
23-
const self = this;
24-
this.loading = true;
25-
this.$auth.register({
26-
data: signUpFormData,
27-
redirect: {name: ROUTE_LOGIN},
28-
success: function (response) {
29-
self.loading = false;
23+
this.$auth
24+
.register({
25+
data: signUpFormData,
26+
})
27+
.then(response => {
3028
if(response.data.status) {
3129
this.$message.success(response.data.status)
3230
} else {
3331
this.$message.success(this.$t('auth.register.success'))
3432
}
35-
},
36-
error: function (error) {
33+
}, error => {
3734
if (error.response.status === 422)
3835
this.authErrors = error.response.data.errors
39-
self.loading = false
40-
},
41-
})
36+
})
37+
.finally(() => this.loading = false);;
4238
},
43-
4439
}
4540
}
4641
</script>

tests/Browser/LoginTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,12 @@ public function login_with_valid_credentials()
1919
$browser->visit(new Login)
2020
->submit($user->email, 'password')
2121
->assertPageIs(Admin::class);
22-
});
23-
}
24-
25-
/** @test */
26-
public function log_out_the_user()
27-
{
28-
$user = User::factory()->create();
2922

30-
$this->browse(function ($browser) use ($user) {
31-
$browser->visit(new Login)
32-
->submit($user->email, 'password')
33-
->visit(new Admin)
23+
$browser->visit(new Admin)
3424
->clickLogout()
3525
->assertPageIs(Login::class);
3626
});
27+
3728
}
3829

3930

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,10 +966,10 @@
966966
"@webassemblyjs/wast-parser" "1.9.0"
967967
"@xtuc/long" "4.2.2"
968968

969-
"@websanova/vue-auth@^2.21.14-beta":
970-
version "2.21.14-beta"
971-
resolved "https://registry.yarnpkg.com/@websanova/vue-auth/-/vue-auth-2.21.14-beta.tgz#315c24c5ab4c560a46d832cb1f5a702d054a1dc7"
972-
integrity sha512-p2ahPPxhjknbwOWd+JAIZwqcZY9L1J8l0fYAH6tbIKz+CktvKtGlv4LeNPDtZQQF6ByWXdU1XQ/XFOwyDNjCkQ==
969+
"@websanova/vue-auth@3.3.1":
970+
version "3.3.1"
971+
resolved "https://registry.yarnpkg.com/@websanova/vue-auth/-/vue-auth-3.3.1.tgz#69de455ff6f4922745e4eb1c5763d15872e3cb38"
972+
integrity sha512-Yt5Yi7NQ9UOD2MdlPtu5FzVZ8oJOFnMIEgYnvnqLETEjxLcw9BUROdFBehkZQas91beAwLkKumshqSYP2xePcg==
973973

974974
"@xtuc/ieee754@^1.2.0":
975975
version "1.2.0"

0 commit comments

Comments
 (0)