Saving the username and authkey to stored preferences.

Need to refactor this code.