Hi,
Apologies for the long post
I am trying to get a simple user session working using Node.ACS locally with TiStudio. I have created a basic Node.ACS project and added a few functions to check the ACS API.
in app.js I have added the following
var ACS = require('acs').ACS; ACS.init('{mysecret}', '{mykey}');I have then added
var ACS = require('acs').ACS;to the start of the application.js file. I have modified the index method in application.js as follows
// a test to see if have actually logged in and have a valid session ACS.Users.query({},function (e) { if (e.success) {; console.log(e.users); } else { console.log('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } }, req, res); // a bit of make up to show our page res.render('index', { title: 'Welcome to Node.ACS!'});This all works as I would expect and I get an error as I am not logged in.
I have also added a route and additional method to hard log in a user.
{ "path": "/login", "callback": "application#login" },
function login(req,res){ // log user in and redirect to index ACS.Users.login({ login: 'administrator', password: '{mypwd}' }, function(data) { res.redirect('/'); }, req, res); }Again this works and if I access /login it logs me in , redirects to / and shows the list of users correctly.
I then added a Logout function and route as shown below.
{ "path": "/logout", "callback": "application#logout" }
function logout(req,res){ // Log user out ? ACS.Users.logout(function (e) { if (e.success) { console.log('Success: Logged out'); } else { console('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } res.redirect('/'); }, req,res); }And although this tells me it worked OK, on redirect to / I still see the user list, which means that the session was not removed.
Q. Does this mean Logout in Node.ACS has no meaning ? I would have thought that it should remove the Session/Cookie .
I have also come across a problem with the showMe function. I recoded the index method as shown below.
// a test to see if have actually logged in and have a valid session ACS.Users.showMe(function (e) { if (e.success) {; console.log(e.users); } else { console.log('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } }, req, res); // a bit of make up to show our page res.render('index', { title: 'Welcome to Node.ACS!'});This time when I run the app and login etc. When I redirect to / I always get the following error:
Error: You need to sign in or sign up before continuing.Q. Is there a problem with showMe, or is it something I am doing ? - it seems to take no notice of the session created during login.
Any suggestions ?
Thanks,
Steve.