Anh Tuan Nguyen
Anh Tuan Nguyen

Reputation: 979

Meteor react logout event

I'm using meteor and react with meteor packages: accounts-ui accounts-password

I want to execute a function client side and maybe server side, whenever the current user is logging out or leaving the page.

How can I do that ?

EDIT: I added code I'm using for the login. It's simply the react-meteor tutoral Code on Login Systems. I need an event handler for log out events.

export default class AccountsUIWrapper extends Component {

componentDidMount() {
  // Use Meteor Blaze to render login buttons
  this.view = Blaze.render(Template.loginButtons,
    ReactDOM.findDOMNode(this.refs.container));


}

componentWillUnmount() {
  // Clean up Blaze view
  Blaze.remove(this.view);
}

render() {
  // Just render a placeholder container that will be filled in
  return <span ref="container" />;
 }
}

Upvotes: 1

Views: 810

Answers (1)

Rafael Angeline
Rafael Angeline

Reputation: 337

Inside the action that is fired when your user clicks the Logout Button, you call:

Meteor.logout( function() {
    // your code here, runs when user is successfully logged out
}

Upvotes: 1

Related Questions