Page 1 of 2
Logging out from ionic app
Posted: Thu Oct 15, 2015 12:45 am
by Thomas Anderson7286790
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!
Logging out from ionic app
Posted: Fri Oct 16, 2015 8:24 am
by Serhii Kulibaba
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
Logging out from ionic app
Posted: Fri Oct 16, 2015 10:35 am
by Thomas Anderson7286790
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.
Logging out from ionic app
Posted: Wed Oct 21, 2015 7:24 pm
by Serhii Kulibaba
Please create Model with that variable as child parameter and use scope variable with that model
Logging out from ionic app
Posted: Mon Dec 28, 2015 1:35 pm
by Mwesigwa Ezra
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.
Logging out from ionic app
Posted: Tue Dec 29, 2015 11:04 am
by Illya Stepanov
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.
Logging out from ionic app
Posted: Thu May 12, 2016 3:29 am
by Chris8229138
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
Logging out from ionic app
Posted: Fri May 13, 2016 9:38 am
by Serhii Kulibaba
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.
Logging out from ionic app
Posted: Sun May 15, 2016 10:39 am
by Chris8229138
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
Logging out from ionic app
Posted: Mon May 16, 2016 4:36 pm
by Serhii Kulibaba
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