Protect views in app and authentication


#1

Ok so i hav a app where I have mobile number verification using sms code !

So after verification if the user is verified i set a flag in localstoreage as true !

the on every state change i check for the flag ! If the localstorage is cleared it will ask the client the again verify mobile number !

so am i doing the right thing ? is the approach good ? can i use any other more efficient method ?

should i check the user session on every state change via http ?

Is there any standard way for authenticating user?


#2

Most users have been using oauth verification for their apps. But from what you have setup, it seems pretty quick and easy.

Something you could do is to set a serves which checks the localstorage value. So every minute/ 5mins/ or what every time interval you want, the service checks to see if that value still is true


#3

@mhartington can you provide any ref link to the oauth process used in ionic ?


#4

A simple search will get you the info you want.


#5

I actually needed something like that for a few apps I’m working on. I spent quite some time investigating this and was able to achieve something that worked for me.
I’m pretty happy with the result, in addition to email/password authentication I’ve added some social authentication which works in the same way.

  1. open url on client side with the provider’s (facebook/twitter/instagram) url for login
  2. the user logs in and is redirected to the server’s callback url (my server is written in nodejs)
  3. once I’ve got the access token from the provider. I save this token and then create a token for the client to reuse every time the user wants to access a protected ressource.

Download the apk and test it.

If this is what you’re looking for you can checkout both the client side code at : https://github.com/malikov/Authenticate.me-client-cordova-ionic

And the server side code at : https://github.com/malikov/Authenticate.me-Node-Server