[RC2] hotfix - oAuth to app user linking

- fixed problem with non-existent variable `$usernem` at the time of use
- optimized selecting user, if already linked
- thrown exception on database failure now contains exception, that caused it