Fixes function scope and login issues

* Fixed scoping issue with function call to `pkcs5pad`.

* Fix for for when the user logged in with an email address, photos would not be returned because fetch() wasn't using the real username.