Jump to content

Logging A User Out Via The Api


gutterboy

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

 

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).

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...