PHP Classes

File: resources/js/composables/useAuth.js

Recommend this page to a friend!
  Packages of Niko Peikrishvili   Ticker   resources/js/composables/useAuth.js   Download  
File: resources/js/composables/useAuth.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Ticker
Application to track and manage to do tasks
Author: By
Last change:
Date: 2 months ago
Size: 878 bytes
 

Contents

Class file image Download
import { usePage, router } from '@inertiajs/vue3'; import { computed } from 'vue'; import axios from 'axios'; export function useAuth() { const page = usePage(); const user = computed(() => page.props.auth?.user); const isAuthenticated = computed(() => !!user.value); const logout = () => { router.post('/logout'); }; const updateProfile = async (data) => { const response = await axios.put('/api/profile', data); if (response.data.success) { page.props.auth.user = response.data.user; } return response.data; }; const updatePassword = async (data) => { const response = await axios.put('/api/profile/password', data); return response.data; }; return { user, isAuthenticated, logout, updateProfile, updatePassword, }; }