2016-05-24 33 views
1

我使用流星和流星與反應套餐: accounts-ui accounts-password流星反應註銷事件

我想執行一個功能的客戶端,也許服務器端,只要當前用戶被註銷或離開頁面。

我該怎麼做?

編輯:我添加了用於登錄的代碼。這只是登錄系統上的反應 - 流星tutoral 代碼。我需要一個註銷事件的事件處理程序。

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" />; 
} 
} 
+0

[Meteor.logout](http://docs.meteor.com/#/full/ meteor_logout) –

回答

1

裏面當你的用戶點擊退出按鈕時激發的動作,你叫:

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

你能告訴我在哪裏可以找到這個動作嗎? –

+0

正確的做法是在註銷按鈕中添加一個onClick事件,當它被點擊時,你應該調用一個先前聲明的方法。使用'Meteor.call(...)' - 就像你可以在這裏看到的一樣 - https://www.meteor.com/tutorials/react/security-with-methods –

+0

我把我的代碼添加到第一篇文章中,它使用了模板,我無法添加到代碼中,也許您可​​以幫助 –