gutterboy Posted September 14, 2014 Report Posted September 14, 2014 I noticed there is a user::logout method and according to the docs it requires the users "session" to be passed in; my question is how do I get this information for the user to pass to the user::logout method? Thanks! Quote
flangefrog Posted September 14, 2014 Report Posted September 14, 2014 It doesn't look like this method is designed to be called via the API. You would need to instantiate a Session object and select the users session using their session ID, which will be stored in a cookie on the users computer. You could search through the session data on the DB for the client id but it would be messy. Quote
gutterboy Posted September 14, 2014 Author Report Posted September 14, 2014 It doesn't look like this method is designed to be called via the API. You would need to instantiate a Session object and select the users session using their session ID, which will be stored in a cookie on the users computer. You could search through the session data on the DB for the client id but it would be messy. Thanks for the reply. Basically what I am doing is I am using the shared login plugin cody made to log the user into Blesta at the same time as they log into our main site, so when they log out of our main site I want to log them out of Blesta as well. Quote
flangefrog Posted September 14, 2014 Report Posted September 14, 2014 I think that just as you redirect the client to a login url (or make a get request), you would do the same but use the logout url. Quote
gutterboy Posted September 14, 2014 Author Report Posted September 14, 2014 I think that just as you redirect the client to a login url (or make a get request), you would do the same but use the logout url. If I just redirected them to the logout URL then that's where they would end; I need the process to be seamless so they end up back on the main page of the site - which is where they are sent now when they log out. Quote
flangefrog Posted September 14, 2014 Report Posted September 14, 2014 If you can't get the user to make a get request and you need it to be seamless then you could get Blesta to redirect users to your main page after logging out. So there will be two redirects upon logging out of your main site. Quote
gutterboy Posted September 14, 2014 Author Report Posted September 14, 2014 If you can't get the user to make a get request and you need it to be seamless then you could get Blesta to redirect users to your main page after logging out. So there will be two redirects upon logging out of your main site. Well I'm sure I can redirect the user via a GET request to the blesta log out, but not sure how to get blesta to do a redirect after logging them out? Quote
flangefrog Posted September 14, 2014 Report Posted September 14, 2014 I was referring to an ajax get request. If you want to do a redirect then modify this line in app/controllers/client_logout.php $this->redirect($this->base_uri . "login"); Quote
gutterboy Posted September 14, 2014 Author Report Posted September 14, 2014 I was referring to an ajax get request. If you want to do a redirect then modify this line in app/controllers/client_logout.php $this->redirect($this->base_uri . "login"); Oh ok - thanks! Quote
gutterboy Posted September 14, 2014 Author Report Posted September 14, 2014 I was referring to an ajax get request. If you want to do a redirect then modify this line in app/controllers/client_logout.php $this->redirect($this->base_uri . "login"); Hmmm ok, had a look at this. Pretty new to working with the blesta code myself, is there a way I can extend this or something so I can change it so I can pass in a redirect url or something? Because it will vary depending on the environment (dev/test/prod). Quote
Blesta Addons Posted September 14, 2014 Report Posted September 14, 2014 Thanks for the reply. Basically what I am doing is I am using the shared login plugin cody made to log the user into Blesta at the same time as they log into our main site, so when they log out of our main site I want to log them out of Blesta as well. you need to use setSessionCookie function setSessionCookie( string $path = "", string $domain = "", boolean $secure = false ) then you can get a shared $_SESSION . you need to set $_SESSION['blesta_id'] = $user->id; $_SESSION['blesta_client_id'] = $client->id; after the logout destory the session . Quote
gutterboy Posted September 14, 2014 Author Report Posted September 14, 2014 you need to use setSessionCookie function setSessionCookie( string $path = "", string $domain = "", boolean $secure = false ) then you can get a shared $_SESSION . you need to set $_SESSION['blesta_id'] = $user->id; $_SESSION['blesta_client_id'] = $client->id; after the logout destory the session . Hmmmm..... I'd prefer to do it another way, but if I chose to do it that way where would I put that code? You mean in our main system? Quote
Blesta Addons Posted September 14, 2014 Report Posted September 14, 2014 you should run setSessionCookie with api command ..... Quote
gutterboy Posted September 15, 2014 Author Report Posted September 15, 2014 you should run setSessionCookie with api command ..... Ok thanks! Quote
gutterboy Posted September 15, 2014 Author Report Posted September 15, 2014 I ended up commenting out the redirect in that file and then making a very simple plugin that triggers the redirect after the logout event. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.