creating an authentication mechanism with AngularJ

2019-07-11 20:41发布

问题:

I try to create with angularjs based Ionic app an authentication mechanism. The system looks like this:

mobile users are created by administrators on the server. This created mobile user can login into the app.

The users are stored on the server in a JSON object. I had imagined the steps as following?

  1. The link to the JSON object should be parsed.
  2. The created users and passwords on the server are to be compared with the locally login data
  3. If the user has successfully logged into the system, the user data should be stored locally.

Edit:

The flow of the authentication will be effected as follows:

How to create a login system like this programmatically?

回答1:

The steps should be

1) Send username password to server using $http.post();

2) Server authenticates the credentials. and returns a token in return is credentials are correct.

3) App stores this token locally and passes it to server for later request as a mean of identification of logged in user.

Ideally you should implement SOAP or REST based services on your server and consume those services in your app.