Connect to Wi-Fi via command line that requires username and password
It does sound like you are trying to connect to an enterprise network and you have 802.11x authentication. 

If this is NOT the case and you need to enter a username/password in a web page, then you may need to create an AppleScript/Automator function to handle that.

In any event, to connect to an 802.11x network with authentication, you need a network profile.  To create one, you either need OS X Server or you can use Apple Configurator.  It's a free application available from Apple.

While it is geared toward iOS, you can create wi-fi profiles then export them.  Once you have the xml file, you import it with networksetup.

Or...

You can edit the xml file directly which is not something trivial.