Ricardo Amaral
Posts: 0
Joined: Thu Mar 17, 2016 7:33 pm

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

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

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

Panos7842055
Posts: 0
Joined: Sat Oct 31, 2015 8:16 am

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

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

Is there a more "secure" way?

Thanks.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

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

Ricardo Amaral
Posts: 0
Joined: Thu Mar 17, 2016 7:33 pm

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

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?

Martand
Posts: 0
Joined: Tue Jul 05, 2016 5:40 pm

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

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

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

Hello Martand,

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

Return to “Issues”