Skip to content

Commit a7a25e5

Browse files
refactor: removed unnecessary code and comments
1 parent 09145d3 commit a7a25e5

15 files changed

Lines changed: 40 additions & 524 deletions

app/_layout.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ export default function RootLayout() {
2121
});
2222

2323
useEffect(() => {
24-
// Reset initialization on app start
2524
AuthInitializer.reset();
2625

27-
// Setup notification listeners
2826
const notificationListener =
2927
NotificationService.addNotificationReceivedListener((notification) => {
30-
// Limited log - only notification type
3128
console.log(
3229
"📱 Notification received:",
3330
notification.request.content.title
@@ -41,7 +38,6 @@ export default function RootLayout() {
4138
"📱 Notification tapped:",
4239
response.notification.request.content.title
4340
);
44-
// Add notification tap handling logic here
4541
}
4642
);
4743

@@ -52,7 +48,6 @@ export default function RootLayout() {
5248
}, []);
5349

5450
if (!loaded) {
55-
// Async font loading only occurs in development.
5651
return null;
5752
}
5853

app/dashboard.tsx

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useLocalSearchParams } from "expo-router";
2-
import React, { useEffect, useRef } from "react";
2+
import React, { useEffect, useRef, useState } from "react";
33
import { Alert, SafeAreaView, StyleSheet } from "react-native";
44
import { AuthWebView, AuthWebViewRef } from "../components/AuthWebView";
55
import FloatingActionButton from "../components/FloatingActionButton";
@@ -23,6 +23,7 @@ export default function DashboardScreen() {
2323
const isBiometricLogin = params.biometricLogin === "true";
2424

2525
const webViewRef = useRef<AuthWebViewRef>(null);
26+
const [credentialsSaved, setCredentialsSaved] = useState(false);
2627

2728
// Use hooks for state management
2829
const authStateHook = useAuthState({
@@ -42,36 +43,35 @@ export default function DashboardScreen() {
4243
formCapture.setFormCredentials(credentials);
4344
},
4445
onSessionExtracted: async (sessionData) => {
45-
console.log("🔔 [Dashboard] Session extracted successfully");
46+
// Create token from session and login
47+
const tokenResponse =
48+
webViewMessages.createSessionTokenResponse(sessionData);
49+
handleLoginSuccess(tokenResponse);
50+
authStateHook.setIsLoggingIn(false);
4651

47-
// Save login credentials if available
48-
if (authState.isAuthenticated) {
52+
// Save login credentials if available - AFTER handleLoginSuccess sets isAuthenticated = true
53+
if (!credentialsSaved) {
4954
const credentialsForSaving =
5055
formCapture.getCredentialsForSaving(isBiometricLogin);
56+
5157
if (credentialsForSaving) {
5258
await biometricAuth.promptToStoreCredentials(credentialsForSaving);
59+
setCredentialsSaved(true); // Oznacz że dane zostały zapisane
5360
}
5461
}
55-
56-
// Create token from session and login
57-
const tokenResponse =
58-
webViewMessages.createSessionTokenResponse(sessionData);
59-
handleLoginSuccess(tokenResponse);
60-
authStateHook.setIsLoggingIn(false);
6162
},
6263
onSessionExtractionError: (error) => {
6364
console.error("🔔 [Dashboard] Session extraction error:", error);
6465
},
6566
});
6667

67-
// Inicjalizacja OAuth dla normalnego logowania
6868
useEffect(() => {
6969
if (isLoginMode && !isBiometricLogin && !authState.isAuthenticated) {
70+
setCredentialsSaved(false);
7071
oauth.initializeAuth();
7172
}
7273
}, [isLoginMode, isBiometricLogin, authState.isAuthenticated]);
7374

74-
// Inicjalizacja logowania biometrycznego
7575
useEffect(() => {
7676
if (isBiometricLogin && !authState.isAuthenticated) {
7777
initializeBiometricAuth();
@@ -86,9 +86,6 @@ export default function DashboardScreen() {
8686
if (credentials) {
8787
formCapture.setBiometricCredentials(credentials);
8888
await oauth.initializeAuth();
89-
console.log(
90-
"🔐 [Dashboard] Gotowe do automatycznego uzupełniania formularza"
91-
);
9289
} else {
9390
Alert.alert(
9491
"Brak danych",
@@ -113,23 +110,19 @@ export default function DashboardScreen() {
113110
return;
114111
}
115112

116-
// Sprawdź callback OAuth2
117113
if (oauth.isCallbackUrl(navState.url)) {
118-
console.log("🌐 [Dashboard] Detected OAuth callback");
119-
120114
const success = await oauth.handleAuthCallback(navState.url);
121115

122116
if (success) {
123117
authStateHook.setIsLoggingIn(false);
124118

125-
// Zapisz dane logowania po udanym logowaniu
126119
const credentialsForSaving =
127120
formCapture.getCredentialsForSaving(isBiometricLogin);
121+
128122
if (credentialsForSaving) {
129123
await biometricAuth.promptToStoreCredentials(credentialsForSaving);
130124
}
131125

132-
// Przekieruj do dashboardu inFakt
133126
setTimeout(() => {
134127
const redirectScript = createRedirectScript(
135128
"https://front.sandbox-infakt.pl"
@@ -174,7 +167,6 @@ export default function DashboardScreen() {
174167
setTimeout(() => {
175168
authStateHook.handleLogout();
176169

177-
// Przekieruj do strony głównej inFakt
178170
const redirectScript = createRedirectScript(
179171
"https://front.sandbox-infakt.pl"
180172
);
@@ -186,15 +178,13 @@ export default function DashboardScreen() {
186178
}
187179
};
188180

189-
// Określ URL do załadowania
190181
const webViewUrl =
191182
authStateHook.isLoggingIn && oauth.authUrl
192183
? oauth.authUrl
193184
: "https://front.sandbox-infakt.pl";
194185

195186
return (
196187
<SafeAreaView style={styles.container}>
197-
{/* Navigation bar - hide in login mode */}
198188
{!authStateHook.isLoggingIn && authState.isAuthenticated && (
199189
<NavigationBar
200190
canGoBack={authStateHook.canGoBack}
@@ -206,7 +196,6 @@ export default function DashboardScreen() {
206196
/>
207197
)}
208198

209-
{/* Login bar */}
210199
{authStateHook.isLoggingIn && (
211200
<LoginBar
212201
isBiometricLogin={isBiometricLogin}

app/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ export default function IndexScreen() {
1616
}
1717
}, [isLoading, authState.isAuthenticated]);
1818

19-
// Show loading screen while checking authentication
2019
return <SplashScreen />;
2120
}

app/login.tsx

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default function LoginScreen() {
1717
biometricAvailable,
1818
hasStoredBiometricCredentials,
1919
getBiometricTypeLabel,
20-
clearStoredBiometricCredentials,
2120
} = useAuth();
2221
const [isLoading, setIsLoading] = useState(false);
2322
const [isBiometricLoading, setIsBiometricLoading] = useState(false);
@@ -26,30 +25,11 @@ export default function LoginScreen() {
2625
useEffect(() => {
2726
// Check for stored login credentials when component mounts
2827
const checkStoredCredentials = async () => {
29-
console.log("🔍 [LoginScreen] Checking for stored login credentials...");
30-
console.log("🔍 [LoginScreen] Biometrics available:", biometricAvailable);
31-
3228
if (biometricAvailable) {
33-
console.log(
34-
"🔍 [LoginScreen] Calling hasStoredBiometricCredentials..."
35-
);
3629
const hasCredentials = await hasStoredBiometricCredentials();
3730

38-
console.log(
39-
"🔍 [LoginScreen] Credentials check result:",
40-
hasCredentials ? "✅ Data exists" : "❌ No data"
41-
);
42-
4331
setHasStoredCredentials(hasCredentials);
44-
45-
console.log(
46-
"🔍 [LoginScreen] Face ID button will be",
47-
hasCredentials ? "shown" : "hidden"
48-
);
4932
} else {
50-
console.log(
51-
"🔍 [LoginScreen] Biometrics unavailable - Face ID button hidden"
52-
);
5333
setHasStoredCredentials(false);
5434
}
5535
};
@@ -64,12 +44,8 @@ export default function LoginScreen() {
6444
};
6545

6646
const handleBiometricLogin = async () => {
67-
console.log("🎯 [LoginScreen] Face ID button clicked");
68-
6947
setIsBiometricLoading(true);
7048
try {
71-
console.log("🎯 [LoginScreen] Starting biometric login process...");
72-
7349
// Redirect to dashboard with biometricLogin flag
7450
router.replace("/dashboard?loginMode=true&biometricLogin=true" as any);
7551
} catch (error) {
@@ -92,34 +68,10 @@ export default function LoginScreen() {
9268
[{ text: "OK" }]
9369
);
9470
} finally {
95-
console.log("🎯 [LoginScreen] Finishing biometric login process");
9671
setIsBiometricLoading(false);
9772
}
9873
};
9974

100-
const clearBiometricData = async () => {
101-
try {
102-
console.log("🗑️ [LoginScreen] Clearing biometric data...");
103-
104-
await clearStoredBiometricCredentials();
105-
106-
// Refresh stored credentials check
107-
const hasCredentials = await hasStoredBiometricCredentials();
108-
setHasStoredCredentials(hasCredentials);
109-
110-
console.log("🗑️ [LoginScreen] ✅ Biometric data cleared");
111-
112-
Alert.alert(
113-
"Data Cleared",
114-
"Stored biometric data has been removed. You can now log in using standard method.",
115-
[{ text: "OK" }]
116-
);
117-
} catch (error) {
118-
console.error("🗑️ [LoginScreen] ❌ Error clearing data:", error);
119-
Alert.alert("Error", "Failed to clear biometric data.", [{ text: "OK" }]);
120-
}
121-
};
122-
12375
const handleDebugInfo = () => {
12476
Alert.alert(
12577
"Debug Info",

hooks/useAuthState.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ export const useAuthState = (
6969
style: "destructive",
7070
onPress: async () => {
7171
try {
72-
console.log("🔓 [useAuthState] Starting logout process...");
73-
7472
// Reset local state
7573
setCanGoBack(false);
7674
setCanGoForward(false);
@@ -84,8 +82,6 @@ export const useAuthState = (
8482
} else {
8583
router.replace("/login" as any);
8684
}
87-
88-
console.log("🔓 [useAuthState] Logout completed");
8985
} catch (error) {
9086
console.error("🔓 [useAuthState] Logout error:", error);
9187
// Despite error, redirect to login
@@ -98,8 +94,6 @@ export const useAuthState = (
9894

9995
const handleCancelLogin = useCallback(() => {
10096
try {
101-
console.log("🔓 [useAuthState] Canceling login process...");
102-
10397
// Reset local state
10498
setCanGoBack(false);
10599
setCanGoForward(false);
@@ -111,11 +105,8 @@ export const useAuthState = (
111105
} else {
112106
router.replace("/login" as any);
113107
}
114-
115-
console.log("🔓 [useAuthState] Login cancellation completed");
116108
} catch (error) {
117109
console.error("🔓 [useAuthState] Login cancellation error:", error);
118-
// Despite error, redirect to login
119110
router.replace("/login" as any);
120111
}
121112
}, [onLogoutComplete]);

hooks/useBiometricAuth.ts

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,15 @@ export const useBiometricAuth = (options: UseBiometricAuthOptions = {}) => {
4646
try {
4747
setState((prev) => ({ ...prev, isLoading: true, error: null }));
4848

49-
console.log(
50-
"🔐 [useBiometricAuth] Loading stored biometric credentials..."
51-
);
52-
5349
const credentials = await getStoredCredentials();
5450

5551
if (credentials) {
56-
console.log(
57-
"🔐 [useBiometricAuth] Biometric credentials loaded successfully:",
58-
{
59-
hasUsername: !!credentials.username,
60-
hasPassword: !!credentials.password,
61-
usernameLength: credentials.username?.length || 0,
62-
passwordLength: credentials.password?.length || 0,
63-
}
64-
);
65-
6652
if (onSuccess) {
6753
onSuccess(credentials);
6854
}
6955

7056
return credentials;
7157
} else {
72-
console.log(
73-
"🔐 [useBiometricAuth] No stored biometric credentials found"
74-
);
7558
return null;
7659
}
7760
} catch (error) {
@@ -111,8 +94,6 @@ export const useBiometricAuth = (options: UseBiometricAuthOptions = {}) => {
11194
try {
11295
setState((prev) => ({ ...prev, isLoading: true, error: null }));
11396

114-
console.log("🔐 [useBiometricAuth] Storing biometric credentials...");
115-
11697
const storedCredentials: StoredCredentials = {
11798
username: credentials.username,
11899
password: credentials.password,
@@ -121,14 +102,7 @@ export const useBiometricAuth = (options: UseBiometricAuthOptions = {}) => {
121102
const success = await storeBiometricCredentials(storedCredentials);
122103

123104
if (success) {
124-
console.log(
125-
"🔐 [useBiometricAuth] Biometric credentials stored successfully"
126-
);
127105
if (onStorageSuccess) onStorageSuccess();
128-
} else {
129-
console.log(
130-
"🔐 [useBiometricAuth] Failed to store biometric credentials"
131-
);
132106
}
133107

134108
return success;
@@ -156,25 +130,16 @@ export const useBiometricAuth = (options: UseBiometricAuthOptions = {}) => {
156130
const promptToStoreCredentials = useCallback(
157131
async (credentials: BiometricCredentials): Promise<void> => {
158132
if (!biometricAvailable) {
159-
console.log(
160-
"🔐 [useBiometricAuth] Biometrics unavailable - skipping credential storage"
161-
);
162133
return;
163134
}
164135

165136
try {
166-
console.log(
167-
"🔐 [useBiometricAuth] Displaying biometric storage dialog..."
168-
);
169-
170137
const storedCredentials: StoredCredentials = {
171138
username: credentials.username,
172139
password: credentials.password,
173140
};
174141

175142
await askToStoreCredentials(storedCredentials);
176-
177-
console.log("🔐 [useBiometricAuth] Storage dialog completed");
178143
} catch (error) {
179144
console.error(
180145
"🔐 [useBiometricAuth] Error displaying storage dialog:",
@@ -193,13 +158,7 @@ export const useBiometricAuth = (options: UseBiometricAuthOptions = {}) => {
193158
try {
194159
setState((prev) => ({ ...prev, isLoading: true, error: null }));
195160

196-
console.log("🔐 [useBiometricAuth] Clearing biometric credentials...");
197-
198161
await clearStoredBiometricCredentials();
199-
200-
console.log(
201-
"🔐 [useBiometricAuth] Biometric credentials cleared successfully"
202-
);
203162
} catch (error) {
204163
const errorMessage = "Nie udało się wyczyścić danych biometrycznych";
205164
console.error("🔐 [useBiometricAuth] Error clearing credentials:", error);

0 commit comments

Comments
 (0)