Back

[SOLVED] Unable to create account

  • 0
  • Accounts
  • Web
Collin
29 Oct, 2023, 09:36

I keep getting the error A user with the same id, email, or phone already exists in this project., I have tried looking through previous posts and docs. None of which seems to help resolve the issue. I am selfhosting, and if i create an account from the dashboard it is fine. My code is below.

TypeScript
import { SafeAreaView, TouchableOpacity } from "react-native";
import { Card, Text, TextInput } from "react-native-paper";
import {Account, Client, ID } from "appwrite";
import PropTypes from "prop-types";
import { validateName, validateEmail, validatePassword } from "../../utils/validators";

import AuthLogo from "../../components/AuthLogo";
import AppStyle from "../../styling/AppStyling";
import AuthStyle from "../../styling/AuthStyling";

SignUpScreen.propTypes = {
    navigation: PropTypes.shape({
        navigate: PropTypes.func.isRequired,
    }).isRequired,
};

export default function SignUpScreen({ navigation }) {
    const [firstName, setFirstName] = useState("");
    const [lastName, setLastName] = useState("");
    const [email, setEmail] = useState("");
    const [password, setPassword] = useState("");
    const [confirmPassword, setConfirmPassword] = useState("");

    const client = new Client();

    client
        .setEndpoint("Omitted")
        .setProject("Omitted");

    const handleSignUp = async () => {

        const account = new Account(client);

        const promise = await account.create(ID.unique(), email, password, `${firstName} ${lastName}`);

        promise.then(function () {
            navigation.navigate("Login");
        }, function (error) {
            console.log(error); // Failure
        });
    };```
TL;DR
User is unable to create an account and is getting the error "A user with the same id, email, or phone already exists in this project." User is using React Native with Expo. They have checked the documentation and previous posts but have not found a solution. They are self-hosting and creating an account from the dashboard works fine. They provided code for creating the account.
Drake
29 Oct, 2023, 15:11

Check the network logs in the browser to see what's being sent to the server for the payload

Collin
29 Oct, 2023, 16:53

I'm using react native w/ expo. I know there is an option to open in the web, but it won't build a usable app. Do you know of another way to see the payload?

Drake
29 Oct, 2023, 17:15

Then try logging the parameters before calling the create

Collin
29 Oct, 2023, 17:22

I did try this last night, but I did try it again for you

Collin
29 Oct, 2023, 17:23

Is that what ID.unique( ) is supposed to return?

Drake
29 Oct, 2023, 17:23

Yep that's expected

Drake
29 Oct, 2023, 17:24

And no user with that email already exists?

Collin
29 Oct, 2023, 17:25

correct, I have tried with several different emails. All of which return that same error. I have even tried hardcoding a string into the create function as well. But to no avail, I keep getting that same error when trying to create the account.

Collin
29 Oct, 2023, 17:25

I checked the docs to make sure all params are in the correct order and valid

Drake
29 Oct, 2023, 17:26

What happens if you call account.get() before the create?

Collin
29 Oct, 2023, 17:26

does it take any arguments?

Drake
29 Oct, 2023, 17:27

No

Collin
29 Oct, 2023, 17:27

Okay, one moment

Collin
29 Oct, 2023, 17:29

So that is showing that I am logged in using an account I created manually but never logged in with?

Collin
29 Oct, 2023, 17:30

when i use the account.get( )

Drake
29 Oct, 2023, 17:30

The SDK persists sessions automatically. So you're seeing the weird behavior because you're already logged in but trying to create an account again

Collin
29 Oct, 2023, 17:33

okay, thank you. So when you create an account, it automatically logs the user in? Or would I had to have logged in using the createEmailSession? Also do you happen to have the code for logging out of a session?

Drake
29 Oct, 2023, 17:36

No, it doesn't automatically log the user in

Drake
29 Oct, 2023, 17:36

To log out, use the delete session API

Collin
29 Oct, 2023, 17:41

Okay, I am not sure exactly how that happened. This is for a group project, so maybe one of my group partners may have logged it in. My apologies, thank you for the help. But that fixed it. Thank you!

Drake
29 Oct, 2023, 18:44

[SOLVED] Unable to create account

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more