Solved

Login with Angular JS

Posted on 2014-11-19
3
161 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Facebook React and SyntheticEvents 6 49
Apply tab index in forms 6 33
Regex in JavaScript to validate US phone number with hyphens 3 28
Message not shown 5 33
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

920 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

14 Experts available now in Live!

Get 1:1 Help Now