Reputation: 3466
I'm a complete newbie to any sort of javascript web app stuff (I've only really done some DOM stuff and jquery for flashy effects and whatnot), and I'm having trouble wrapping my head around how to pretty much have a user login and having models only retrieving that user's things.
What I have so far (which I am sure is wrong, I just haven't found anything to show what else to do) is a user model (holds name, email and a js object with basic settings such as country), and a receipts model (it's a basic finance app) which contains basic number stuff and should have a user attribute pointing to user instance. If needed I'll post the models here (I am probably going to host it on github when I get it somewhat working.
I am thinking that I would have to have the user login initially, then all the backend responses will only contain the logged in user's records, but I am not sure if that is the best way to go about it.
Thanks heaps for any help!
Upvotes: 0
Views: 345
Reputation: 110892
Normally you will have a login formular, setting a session cookie after the user passed the right username/password. Know every time the user sends a request to your backend he pass the session cookie and your backend have to verify that the user allowed to get the data he is requesting.
In your application we first get a modle with all user relevant data, like name and a unique user id. After that we call our REST api with routes like this myApp.com/user/uniquieUserId/invoices
for example.
Upvotes: 1