?
Solved

Login with Angular JS

Posted on 2014-11-19
3
Medium Priority
?
170 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

752 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