Translation:If I had a username, I could log in.
People use the a/an rule based on the sound the first syllable of a word begins with, not the actual letter it begins with (as you might have learned in ESL classes). Username starts with a 'y' sound (the same as in yellow or yak), and the 'y' sound is considered a consonant in English, and so we use 'a' rather than 'an'. An username would sound unnatural, because it's like you're saying, "An yusername'.
You'll see the same thing happen in American English with the word 'herb'. Americans drop the h and pronounce it 'erb', and therefore they say 'an herb' (an erb) rather than 'a herb', even though the second, according to a strict interpretation of the a/an rule, should be correct.