-1

I have created UI for users to create their own username and password. Username and passwords are stored in JSON format.

Workflow:

  1. When user clicks on Register Button, user will be presented with UI screen with username and password input text fields

  2. When user enters username it invokes blur event which captures the value entered into input text field

My goal is to check the user entered username already exists or not. If username exists it should ask user to create new one. So duplicate usernames should not be allowed

How can we check for duplicates ??

zoranc
  • 2,410
  • 1
  • 21
  • 34

1 Answers1

0

The workflow is basically:

  1. Create a user model instance on the client (with the username, etc.)
  2. save the model instance, which will send an API request
  3. on your server, check the username for duplicates. If a user with that username already exists, return an error code (e.g. 422 Unprocessable entity)
  4. catch the error on the client (e.g. in the error callback) and process it
David Sulc
  • 25,946
  • 3
  • 52
  • 54