Modify @login_required to handle xhr

@login_required will return 401 with json for xhr request for guest
user. As designed followed by github.
Refer: http://developer.github.com/v3/#failed-login-limit

Detailed response is as following:

Status: 401 UNAUTHORIZED
Body:
{
    "error":true,
    "reason":"This request can only be completed after login"
}