Django/Vue braces added to request method after logout - django

I have a basic user management project that I'm using off of which to scaffold other projects. It is a Vue CLI 3 front end and Django/Django REST Framework/Django REST Auth back end. The project I'm posting here uses sqllite but it can relatively easily be converted to another db.
Here is the link to the full repo for anyone who is willing to download to try to replicate my issue: https://github.com/JVP3122/user-project
I'm having a very strange problem in that when I log out of the site and then try to log back in directly from the same page it seems that axios is adding the payload to the beginning of the request method.
For example, in the images found in the post I put up in Imgur (https://imgur.com/a/bEsx662) the user name is simply "test" with the password "password", and when I try to log back in after logging out the subsequent login attempt is no longer a POST route, but instead a {}POST route. If I try again, the route becomes a {"USERNAME":"TEST","PASSWORD":"PASSWORD"}POST method.
I've tried looking at the config in the axios request interceptor, looking at the dispatch method in the rest_framework source code, and I can't figure out what is going on or how to solve this. It's a small bug that doesn't take away from the rest of the functionality, but it's a bug nonetheless.
Any help would be appreciated.

Did you try:
setting up new project (npm reinstall, clear npm cache etc..)
using axios.post instead of custom made HTTP object
I don't see anything in the backend that could interrupt the request and customise method as described in the original post.
Hopefully one of these two options above will resolve it.

Responded in your issue axios/axios#1994.

Related

How to use react-router and Django templates

Folks,
I am pretty sure I am not the first one to stumble on this problem. But somehow I am unable to find any relevant resources out there.
Here is my issue, I have a backend in Django and my front completely written in Reactjs- React Router - Redux (nice combo right).
when entering the url webhost.com/, django provides me with a page with links to a bundle that is my whole react application and different stylesheets
The problem arise when I want to refresh a page, the browser still tries to query the server even though a route exists in my react-router configuration.
I had a look at the answer here (catch-all option) React-router urls don't work when refreshing or writting manually , but I don't quite understand it and I am afraid to have a new redux state everytime Django will provide the user with a new page.
You can setup up a wildcard url pattern that will render the same view that gets rendered when a request is sent to webhost.com. I don't know if that's going to retain your store though.

Login and template errors deploying meteor to Digital Ocean / modulus.io

Apologies if this question is not asked correctly but I actually can't pinpoint the problem. Hence the lack of code in the question itself. I'm struggling with this error so please go easy on me....
I was developing a meteor app locally without too much difficulty. It seems to run well on localhost. But then I decided to deploy it and have been running into some problems as outlined below. I have deployed the app "successfully" using both mup/DO and modulus.io (with compose hosting the DB in both instances) and whole thing sort of works, but...
You can register fine but when you try to log in the button doesn't work...press it again and you login but the usename and password are in the URL... how does this happen?
When you login you can begin by creating a supplier, then create products for that supplier. Only thing is the suppliers are saved to the DB and they are in the product count but they are nowhere to be seen in the middle section page.
Once you create a new supplier, the add new products for the existing suppliers is no longer accessible.
I am so confounded that I don't know what code to put up so I'm giving access to my codebase - it's on github here and this is the modulus site here. Go ahead and register and you can see for yourself.
You will easily be able to see the errors in the console when you start trying to log into the site so there is no point in posting them here.
Many, many thanks in advance guys.
I have reviewed your code and I don't think that the errors occur due to the deployment.
Here's a list with a few suggestions that should help you to fix your code:
In your /client/helpers/config.js file, you try to configure the behaviour of {{> loginButtons}}. That does not make any sense, since you do not have the accounts-ui package installed.
The /client/templates/includes/header.html file references with pathFor to homepage. This route is currently not available in your /lib/router.js.
Users are able to access the /loggedIn path even if they are not logged in. Furthermore, you always redirect users to this path if the submit form event in the register template occurs. This means, they can easily bypass the registration just by clicking on the submit button.
Watch your console logs. There are a lot of template helper exceptions.
Unfortunately, I could not check the login bug you described, because I received an exception when invoking the submit event. I recommend to use a rather defensive programming approach, you should at least check if the variable's value is not undefined and if it is, then you should handle those situations accordingly.
For example, in your /client/templates/includes/login.js file, you have the following code:
var userId = Meteor.userId();
var supplier = Suppliers.findOne({userId: userId});
var supplierId = supplier._id;
This will raise an exception if supplier is undefined.
All in all, you should rethink your release planning and deployment, since your app is far from working. Furthermore, please try to break your issue into chunks next time and provide a clear problem statement, because your question won't be useful to other readers without it.

How to run Django views from a script?

I am writing a Django management command that visits a few pages, logged in as a superuser, and saves the results to a set of .html files.
Right now I'm just using the requests library and running the command with the development server running. Is there an easy way to generate the HTML from a view response so I do without actual HTTP requests?
I could create a request object from scratch but that seems like more overhead than the current solution. I was hoping for something simple.
Django has a RequestFactory which seems to suit your needs.
While it's not exactly meant for this purpose, an option would be to use the testing framework's Client to fake a request to the url - be sure to use client.login() before making your requests, to ensure you have superuser capabilities.

How to disable Request Method: OPTIONS with ember app kit

Since i'm using EAK, each time I save a model, I have an extra request method. It's more annoying then anything and I'd like to disable it. I haven't found anything in the documentation regarding this. Has anyone ever disabled it or am I stuck with it?
I may be wrong here, but this doesn't sound like a problem with Ember-App-Kit. Are you by any chance using CORS to send your requests? You say that it sends an OPTIONS request when you save a model, but you didn't mention that it sends one when it fetches a model. This makes me think that it's a preflighted request that is unavoidable if you're using CORS. We had this same issue about a month ago and we decided to ditch CORS in favor of a proxy server.
I've never used Ember-App-Kit, but it's just a build tool, so I can't imagine how it would affect your Ember-Data adapter.

pyfacebook #facebook.require_login() decorator causing constant auth_token refresh

First time using pyFacebook. I've literally copied the example application and put it up onto my server. I've created an FB app and now when I try to load the app basically what happens is that the browser keeps refreshing. I noticed in the url (for example)
https://apps.facebook.com/myapp/?auth_token=8f826cae31717068c18fb16fd7f0a758
Keeps refreshing with the auth_token changing. If I remove the #facebook.require_login() decorator then the page displays without a problem.
Help please.
I've just noticed that it only does this when I select IFrame and not FBML within my app settings. I have fbml templates which don't work. I know have normal html templates which work on the website but when I select IFrame I get that constant loop (changing url with blank white screen)
Ok so after weeks of pain the problem I was having was that Facebook updated it's entire API. This broke python based apps that were based on that. Like PyFacebook.
I now use fandjango and this it's new, has a great developer and nice documentation.
The problem is most probably somewhere in facebook/init.py, around line 1742
if not params:
if request.method == 'POST':
params = self.validate_signature(request.POST)
if not params: #was else
iframe makes POST call, but auth_token is GET variable.. though if validate_signature fails (params still None) go to GET validation. Also I commented out the return in auth_token checks as suggested in pyfacebook issue tracker.