#[SOLVED] Problem with login with an Expo/React Native App
6 messages · Page 1 of 1 (latest)
The error is coming from trying to delete the not existing session:
await account.deleteSession('current');
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}`);
}
};
The method should be account.createEmailPasswordSession(). account.createSession() expects a user ID as the first parameter
This worked, thank you so much!
Np. If your issue has been solved, you can mark this post as closed by adding "[SOLVED]" to the beginning of the title