Solved

Login with Angular JS

Posted on 2014-11-19
3
159 Views
Last Modified: 2015-01-02
Hello

I'm fairly new to Angular and turning an excisting PHP web application in to Angular. It's going well so far but I'm now stuck at the login bit and hoping someone can assist

The system has got several users, each operate in their own area where they can add their customers, update them, delete them etc - we are also running reporting for them

This is how the old system worked with login:
API call to the service using CURL / PHP and if the username / password is correct we take the ID of that user and store is in a session

User login -> Check authentication -> Set ID / Tokein Session -> Display data depending on the ID

Now this works fine and after 20min inactivity the session dies, or the client logs out. On each page we check if there is an ID and if not the user is sent to the login page


In Angular JS I thought there would be a session or similar so I could still use the session state, but I can't find anywhere if we can reach the server-side sessions or not ?


So I thought instead of me trying to do something halfway I would like to hear what is the correct way for me to do this

Once in the system everything will operate with the ID, posts, delete, updates etc will always have for the API or SQL statment "WHERE ID =''"

What's the best way of doing this in Angular JS

User login -> Run API call to see if correct -> If yes what ID is there -> Save ID so we can retrieve it from any page further on in the system (just like you can with a session)

Many thanks
0
Comment
Question by:DanteAdmin
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40453689
once the user try to access a page which need access your server (API request) need to send back an error : user not logged so you handle this and goto login page
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now