Skip to content

Create User with Username and Password Only #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
podcoder opened this issue Oct 6, 2020 · 1 comment
Closed

Create User with Username and Password Only #465

podcoder opened this issue Oct 6, 2020 · 1 comment

Comments

@podcoder
Copy link

podcoder commented Oct 6, 2020

I would like to signup a user with username and password only.
But, if I extend the ParseUser class, I need to pass three parameters i.e username, password and email.

class TestUser extends ParseObject implements ParseCloneable {
  TestUser() : super("_User");
  TestUser.clone() : this();

  @override
  TestUser clone(Map<String, dynamic> map) => TestUser.clone()..fromJson(map);

  static const String keyUsername = "username";
  static const String keyPassword = "password";

  String get username => get<String>(keyUsername);
  set username(String username) => set<String>(keyUsername, username);

  String get password => get<String>(keyPassword);
  set password(String password) => set<String>(keyPassword, password);
}

I was able to achieve the functionality I want as follow:

  Future _createUser() async {
    var user = TestUser()..set('username', 'sky12')..set('password', '123456');
    await user.save();
  }

I was wondering if there is a better approach to accomplish this task by extending ParseUser class. Because it will enable me to take full advantages of already implement functionalities.

@fischerscode
Copy link
Contributor

I thought, setting an email is required in order to create a user on the parse server.
But it seems like it is optional, as creating a new user without an email works from the dashboard.

I recommend you to extend your custom class on ParseUser and not on ParseObject.
In the constructor you can set email to null.

The only problem is, that this SDK does currently not support running the signUp() function without and email address due to this if-block. (login() works)

As a workaround you can either provide a dummy email (like [email protected]) or you create the new user first and login afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants