If you are allowing the user to login with their username and password then you have to make sure that every user has a unique username.
When the user goes for registration on your site check username either after form submits or check it with AJAX while entering.
In this tutorial, I am using jQuery AJAX to check username is available or not.