Saving the Comment object after successfull oauth login with Rails' omniauth

╄→尐↘猪︶ㄣ 提交于 2020-01-06 05:38:06

问题


I want rails to either update or store the Comment after a user did a successfull loging trough omniauth (Twitter, Facebook or OpenID).

  1. A (not logged in) user fills in a comment form. Posts that.
  2. User gets an omniauth page where she can choose the sign-in-method: Twitter, Facebook or OpenID.
  3. Once the user returns from the oAuth successfully, I want to store (or publish) the Comment.

I have this working, using a session-variable, but that is not very thread-safe: it will break if a user has multiple comment-tabs open with the same session.

Should I save the comment to the database in an unpublished state, and toggle that after returning? And if so, how to know how to toggle te correct comment? Problem is similar to abovementioned session-issue.

Is there some way to simply pass the comment-object along with the omniauth and recieve it back when the user returns from a successfull sign-in?

Or can I pass some hash-string along that I can extract after a successfull return?

Edit: complete rewrite to simplify and clarify the question.


回答1:


Store post id along with comment text in session. On successful authentication, find the post using stored id and build the comment object for it.

Update - In case authentication fails, delete all such entries.



来源:https://stackoverflow.com/questions/5045689/saving-the-comment-object-after-successfull-oauth-login-with-rails-omniauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!