-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Omniauth developer strategy #41
Conversation
@@ -1,5 +1,5 @@ | |||
def auth_params_for (user) | |||
{ | |||
Hashie::Mash.new({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gemfile
に依存かかかなくてもだいじょうぶですか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omniauthの依存で入ってくるんですねー
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうなんです。
実装の方でも使っていて、OmuniAuthが使うのをやめた時はこけてほしいので書かないままがいいと思います。
便利なので他で使うなら勿論入れちゃっていいと思いますが。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解ですー
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
何かのライブラリで依存しているものを暗黙的に利用すると見通しが悪くなる気がするのですが、そうでもないのですかね?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうかもしれぬ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここ、auth_params_for(:foo).uid みたいにすることが無いなら Hash でも良いような。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hasie::Mash
を使いたいという強い意図を感じたのでそのままにしてありますw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、俺か。遅れてすんません。
Hashie::Mash
を使いたいという強い意図のみなもとはここです。
https://github.com/kentaro/triglav/pull/41/files#L0R14
developer strategyではauth_params
にupdate_image(auth_params['extra']['raw_info']['avatar_url'])
という物が入ってこないので、
update_image(auth_params['extra'] && auth_params['extra']['raw_info'] && auth_params['extra']['raw_info']['avatar_url'])
といったことをしなくちゃいけなくてだるいなあと思ってドットでつなげてtry
とかpresent?
とかを使えるようにしたかったです。
(その他の場所でドットを使うようにしたのはほとんどおまけです)
で、
何かのライブラリで依存しているものを暗黙的に利用すると見通しが悪くなる気がするのですが、
なんですが、OmuniAuthが渡してくれるrequest.env['omniauth.auth']
(auth_params
はこれを返すだけのメソッド)が
そもそもHashie::Mash
なのでテストデータの方でそれに揃えるのは妥当か、(だから↑のように楽しても許されるよね)と思って使いました。
ただまあ、こんな長い説明を要するのを見るに、すっきりしたストラテジーを自作するべきかも知れません……。
Seems OK. Go ahead.
Do you have any idea how you can test that? |
To use |
Naruhodo! Thank you. |
I never came up with such an idea! |
"Sign in as a developer" sounds like "Sign in as a developer who has additional privilegeds."
@kentaro san |
def update_privilege | ||
if Settings.github.try(:organizations).present? | ||
def update_privilege(provider) | ||
if provider == 'github' && Settings.github.try(:organizations).present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use Settings.github.organizations.presence
instead of `Settings.github.try(:organizations).present?``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確かにtry
は全然いりませんね。
if
節の中では述語のpresent?
の方がしっくりくるのですがどうでしょう。
@KitaitiMakoto |
Merge origin/master to this branch, plz. |
コメントが消えていた! |
ソースから該当行が無くなったので「hsbt discussed an outdated diff 2 days ago Show outdated diff」というところに隠れてしまいました。
指摘されて僕もそう思いました。 |
Thanks!!1 Great job!!1 |
@kentaro san said "I want you to do with omniauth
developer
mode." to me at issue #29.I'v done it at RubyWorld Conference 2012.
Usage:
/caveat
.Required Considerations
/auth/developer/callback
is accepted. Is it OK?developer
strategy is activated only whenRAILS_ENV=development
?Thanks!