refactor: Simplify authentication and wallet logic by removing debug logs

- Eliminate console logging from the authentication initialization and login processes in useAuth.ts for cleaner code.
- Streamline wallet computation in useTicketPurchase.ts by removing unnecessary logging while maintaining functionality.
- Refactor LNBits API methods to reduce logging, enhancing code clarity and maintainability.
This commit is contained in:
padreug 2025-08-01 23:25:53 +02:00
parent e1667461be
commit cd0016744b
3 changed files with 6 additions and 54 deletions

View file

@ -13,23 +13,14 @@ export function useAuth() {
*/
async function initialize(): Promise<void> {
try {
console.log('Initializing authentication...')
isLoading.value = true
error.value = null
const isAuth = lnbitsAPI.isAuthenticated()
console.log('Is authenticated:', isAuth)
if (isAuth) {
console.log('Getting current user...')
if (lnbitsAPI.isAuthenticated()) {
const user = await lnbitsAPI.getCurrentUser()
console.log('Current user set:', user)
currentUser.value = user
} else {
console.log('Not authenticated, skipping user fetch')
}
} catch (err) {
console.error('Authentication initialization error:', err)
error.value = err instanceof Error ? err.message : 'Failed to initialize authentication'
// Clear invalid token
await logout()
@ -43,19 +34,15 @@ export function useAuth() {
*/
async function login(credentials: LoginCredentials): Promise<void> {
try {
console.log('Login attempt with credentials:', { username: credentials.username })
isLoading.value = true
error.value = null
await lnbitsAPI.login(credentials)
console.log('Login successful, getting user details...')
// Get user details
const user = await lnbitsAPI.getCurrentUser()
console.log('User details after login:', user)
currentUser.value = user
} catch (err) {
console.error('Login error:', err)
error.value = err instanceof Error ? err.message : 'Login failed'
throw err
} finally {

View file

@ -30,25 +30,10 @@ export function useTicketPurchase() {
}
})
const userWallets = computed(() => {
const wallets = currentUser.value?.wallets || []
console.log('User wallets computed:', {
currentUser: currentUser.value,
wallets: wallets,
walletCount: wallets.length,
hasWallets: wallets.length > 0
})
return wallets
})
const hasWalletWithBalance = computed(() => {
const hasBalance = userWallets.value.some((wallet: any) => wallet.balance_msat > 0)
console.log('Wallet balance check:', {
wallets: userWallets.value,
hasBalance: hasBalance,
walletBalances: userWallets.value.map((w: any) => ({ id: w.id, balance: w.balance_msat }))
})
return hasBalance
})
const userWallets = computed(() => currentUser.value?.wallets || [])
const hasWalletWithBalance = computed(() =>
userWallets.value.some((wallet: any) => wallet.balance_msat > 0)
)
// Generate QR code for Lightning payment
async function generateQRCode(bolt11: string) {