Authenticate user the right way

Fix #1335
Merge pull request #1340 from winzou/fix/authentication

[Core] Authenticate user the right way