#[SOLVED] Problem with login with an Expo/React Native App

6 messages · Page 1 of 1 (latest)

lilac marlin
#

Hi, I'm having problems with using AppWrite in an Expo app. Code + error attached.

Account creation is fine but cannot login to any account.

icy pagoda
lilac marlin
# icy pagoda The error is coming from trying to delete the not existing session: ```javascrip...

Thank you for the response, now getting another error.

 LOG  No existing session to delete, proceeding with login.
 LOG  Attempting login with email: test@gmail.com
 ERROR  Login error: [AppwriteException: Invalid `userId` param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char]

New code:

const handleLogin = async () => {
        try {
            try {
                await account.deleteSession('current');
            } catch (deleteSessionError) {
                console.log('No existing session to delete, proceeding with login.');
            }

            console.log('Attempting login with email:', email);
            const session = await account.createSession(email, password);

            console.log('Session created successfully:', session);
            await SecureStore.setItemAsync('session', JSON.stringify(session));
            Alert.alert('Success', 'Logged in successfully!');
            // render screens
        } catch (error) {
            console.error('Login error:', error);
            Alert.alert('Error', `Login failed: ${error.message}`);
        }
    };
radiant pumice
lilac marlin
#

This worked, thank you so much!

radiant pumice