Skip to content

Commit

Permalink
fixed 401 and logout after password update
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischulz committed Jun 1, 2024
1 parent 63acd89 commit a36ea39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions resources/js/layouts/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export default {
...mapActions(useAuthStore, ['logout']),
},
mounted() {
axios.interceptors.response.use(function (response) {
axios.interceptors.response.use((response) => {
return response;
}, function (error) {
}, (error) => {
console.error(error)
if (error.response.status === 401 || error.response.status === 419) {
if (error.response.data.message === 'CSRF token mismatch.') return
this.logout()
.catch((error) => { console.error(error) })
router.replace({ name: 'Login' })
} else if (error.response.status === 403) {
router.push({ name: 'VerifyEmail' })
Expand Down
5 changes: 2 additions & 3 deletions resources/js/pages/auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
</label>
<input v-model="data.email"
class="p-2 rounded-md shadow-sm bg-white border border-gray-300 text-gray-400 block mt-1 w-full" id="email"
type="email" name="email" required="required" autofocus="autofocus" value="[email protected]">
type="email" name="email" required="required" autofocus="autofocus">
</div>
<div class="mt-4">
<label class="block font-medium text-sm text-gray-500" for="password">
Password
</label>
<input v-model="data.password"
class="p-2 rounded-md shadow-sm bg-white border border-gray-300 text-gray-400 focus:border-green-500 focus:ring focus:ring-green-500 focus:ring-opacity-50 block mt-1 w-full"
id="password" type="password" name="password" required="required" autocomplete="current-password"
value="password">
id="password" type="password" name="password" required="required" autocomplete="current-password">
</div>
<div v-if="errors" class="text-red-500 py-2 font-semibold">
<span>{{ errors.message }}</span>
Expand Down

0 comments on commit a36ea39

Please sign in to comment.