Page 1 of 1

Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Fri Mar 18, 2016 3:39 am
by Ricardo Amaral

Auto login: Is there a sample on how saving credentials at local DB and recovering that each time user open the app?

Also, how to prevent user to push the back button and get back to login page accidentally?


Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Fri Mar 18, 2016 10:15 am
by Serhii Kulibaba

Hello Ricardo,

You can set login/password to localStorage variables and check them of the startScreen. If they aren't empty - login him automatically. Also, you can set $scope variable which you can check on each page and hide back button according to that value


Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Mon Mar 21, 2016 1:40 pm
by Panos7842055

How secure is this approach?
Is this something that is commonly coded?

Is there a more "secure" way?

Thanks.


Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Mon Mar 21, 2016 9:05 pm
by Serhii Kulibaba

There are no more secure sollution for the saving user's name/password on the device. You can set "Session expiration" more than 1 day, so user's session token would be alive a long time, without saving his password


Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Fri Apr 22, 2016 2:48 am
by Ricardo Amaral

Hi! I could auto logon. Now I need clean up the navigation history after logon to prevent user to go back to the login page (because the Android back button is always there).

I tried the both samples below, but it didn't work.

Syntax on Logon Page
pre

var $ionicHistory = Apperyio.get("$ionicHistory");

$ionicHistory.nextViewOptions({
historyRoot : true,
disableBack: true
});

/pre

or syntax after logon page

pre

var $ionicHistory = Apperyio.get("$ionicHistory");

$ionicHistory.clearHistory()

/pre

From this reference: http://ionicframework.com/docs/api/se...

I just found another solution here but I'm curious why $ionicHistory didn't worked?


Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Wed Jan 25, 2017 12:00 pm
by Martand

Any update on the above query? injecting $ionicHistory into controller does not seem to work


Auto login and prevend user going back to login page by pushing back button for ionic

Posted: Wed Jan 25, 2017 9:30 pm
by Serhii Kulibaba

Hello Martand,

Could you clarify what you have tried and what exactly does not work?