Skip to content

Commit

Permalink
bit of authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Naveen-g09 committed Mar 25, 2024
1 parent 71a7f33 commit 70afd63
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
15 changes: 11 additions & 4 deletions app/(tabs)/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
StyleSheet,
Button,
} from "react-native";
import { Link, Redirect } from 'expo-router';

Check warning on line 10 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

`expo-router` import should occur before import of `react`

Check failure on line 10 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

'Link' is defined but never used

Check warning on line 10 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

'Link' is defined but never used

Check warning on line 10 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `'expo-router'` with `"expo-router"`

import AccountSheet from "../../components/bottomSheet";

Check warning on line 12 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups
import { supabase } from "@/utils/supabase";

//TODO: add a notification icon
//TODO: add a profile icon
Expand All @@ -22,12 +24,17 @@ const Account = () => {
const { dismiss } = useBottomSheetModal();
const handleOpenPress = () => bottomSheetRef.current?.present();

const handleSignOut = async () => {
const { error } = await supabase.auth.signOut();
if (error) console.log('Error logging out:', error.message);

Check warning on line 29 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `'Error·logging·out:'` with `"Error·logging·out:"`
else <Redirect href="/" />;

Check warning on line 30 in app/(tabs)/account.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected an assignment or function call and instead saw an expression
};

return (
<ScrollView contentContainerStyle={styles.container}>
<TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}>Personal Details</Text>
</TouchableOpacity>

<TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}>Transactions</Text>
</TouchableOpacity>
Expand All @@ -44,9 +51,9 @@ const Account = () => {
<Text style={styles.buttonText}>Calendar</Text>
</TouchableOpacity>

{/* <TouchableOpacity style={styles.button} onPress={handleOpenPress}>
<Text style={styles.buttonText}> Edit Access</Text>
</TouchableOpacity> */}
<TouchableOpacity style={styles.button} onPress={handleSignOut}>
<Text style={styles.buttonText}>Logout</Text>
</TouchableOpacity>

<Button title="Dismiss" onPress={() => dismiss()} />

Expand Down
12 changes: 7 additions & 5 deletions app/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Alert, StyleSheet, View, AppState } from "react-native";
import { Button, Input } from "react-native-elements";

import { supabase } from "../../utils/supabase";

Check warning on line 5 in app/Auth/Auth.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups
import { Redirect } from "expo-router";

Check warning on line 6 in app/Auth/Auth.tsx

View workflow job for this annotation

GitHub Actions / lint

`expo-router` import should occur before import of `react`

// Tells Supabase Auth to continuously refresh the session automatically if
// the app is in the foreground. When this is added, you will continue to receive
Expand All @@ -27,11 +28,12 @@ export default function Auth() {
email,
password,
});

if (error) Alert.alert(error.message);
else <Redirect href="/(tabs)/" />; // Add this line
setLoading(false);
}

async function signUpWithEmail() {
setLoading(true);
const {
Expand All @@ -41,10 +43,10 @@ export default function Auth() {
email,
password,
});

if (error) Alert.alert(error.message);
if (!session)
Alert.alert("Please check your inbox for email verification!");
else if (!session) Alert.alert("Please check your inbox for email verification!");
else <Redirect href="/(tabs)/" />; // Add this line
setLoading(false);
}

Expand Down
14 changes: 14 additions & 0 deletions app/Auth/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { View, Text } from 'react-native'

Check failure on line 1 in app/Auth/_layout.tsx

View workflow job for this annotation

GitHub Actions / lint

'View' is defined but never used

Check failure on line 1 in app/Auth/_layout.tsx

View workflow job for this annotation

GitHub Actions / lint

'Text' is defined but never used
import React from 'react'
import { Stack } from 'expo-router'

const AuthLayout = () => {
return (
<Stack>
<Stack.Screen name="Auth" options={{headerShown:false}}/>
<Stack.Screen name="Account" options={{headerShown:false}} />
</Stack>
)
}

export default AuthLayout
1 change: 1 addition & 0 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function RootLayoutNav() {
presentation: "modal",
}}
/>
<Stack.Screen name="Auth" options={{ headerShown: false }} />
</Stack>
</ThemeProvider>
</BottomSheetModalProvider>
Expand Down

0 comments on commit 70afd63

Please sign in to comment.