Used ngTokenAuth and devise_toke_auth to implement token based authentication. Various refactorings were needed