Thomas Anderson7286790
Posts: 0
Joined: Sat Dec 20, 2014 3:46 pm

Logging out from ionic app

I have set up an ionic app with login/logout services. App login is successful. I am able to map the user _id and sessionToken to my user model on my login page. When I add a logout button to the login page, I can successfully logout. But I want to add a logout button on another page in the app. However, that page does not have access to the sessionToken. Logout is therefore not successful.

How do I access the sessionToken (or any item in my user model for that matter) on another page? I understand that scope variables assigned on the index page are globally available, but the user _id and sessionToken are returned on the login page.

Thanks!

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

Logging out from ionic app

Hello Thomas,

Please look at this tutorial: https://blog.appery.io/2015/09/how-to...
You have to set up scope variables on the index page

Thomas Anderson7286790
Posts: 0
Joined: Sat Dec 20, 2014 3:46 pm

Logging out from ionic app

I have reviewed this tutorial previously and already tried it for sessionToken. It works fine when manually setting the header.title. Please give me an example of how to set up a scope variable on the index page and then map a value into it returned on a different page.

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

Logging out from ionic app

Please create Model with that variable as child parameter and use scope variable with that model

Mwesigwa Ezra
Posts: 0
Joined: Fri Mar 27, 2015 7:05 am

Logging out from ionic app

I need help with this topic. I a different login page and i need to pass the session token on one page that uploads to the database. i just cant figure it out. i keep getting a Bad request.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Logging out from ionic app

It seems that the issue here is that you can't reach the $scope variable with the token from another scope.

You will need to define your model at index in the init() function:

$scope.sessionToken = "";

After that you will have access to it from every page in your app.

Chris8229138
Posts: 0
Joined: Thu May 12, 2016 3:29 am

Logging out from ionic app

I have the same problem. My login page is different from the page on which the logout button is set up.
For now, I have no problem logging in/signing up. Upon successful login/signup, the app navigates to the page where the logout button is placed. Unfortunately, when clicking the logout button, nothing happens.
I have followed Sergiy's and Illya's suggestions, no luck. Could you please provide step by step instructions or screenshots of the process just in case I missed something?
Thanks

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

Logging out from ionic app

Hello,
Could you clarify what you have tried and what exactly does not work?
Please check if there are any errors in the browser console. You can learn here: https://devcenter.appery.io/documenta... how to open the console.

Chris8229138
Posts: 0
Joined: Thu May 12, 2016 3:29 am

Logging out from ionic app

Hi Sergiy,
Here is the one error that shows up when I run the browser console:
"GET https://api.appery.io/rest/1/db/logout api.appery.io/rest/1/db/logout:1
401 (Unauthorized)".
Could you help me fix this?
Thanks

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

Logging out from ionic app

Could you show us screenshot with request parameters from the browser network tab? It looks like you didn't set header X-Appery-Session-Token here

Return to “Issues”