Open
Conversation
372fa77 to
c68bc59
Compare
Owner
Author
|
ready |
| end | ||
|
|
||
| def generic_callback provider | ||
| @identity = User.from_omniauth(request.env["omniauth.auth"]) |
|
|
||
| @user = @identity || current_user | ||
| if @user.persisted? | ||
| sign_in_and_redirect @user, :event => :authentication |
Collaborator
There was a problem hiding this comment.
event: :authentication
| @@ -0,0 +1,22 @@ | |||
| class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController | |||
| def facebook | |||
| generic_callback "facebook" | |||
Collaborator
There was a problem hiding this comment.
generic_callback :facebook
| end | ||
|
|
||
| def google_oauth2 | ||
| generic_callback "google_oauth2" |
Collaborator
There was a problem hiding this comment.
generic_callback :google_oauth2
| :recoverable, :rememberable, :trackable, :validatable, :confirmable | ||
| devise :database_authenticatable, :registerable, :validatable, | ||
| :recoverable, :rememberable, :trackable, :confirmable | ||
| devise :omniauthable, :omniauth_providers => [:facebook, :google_oauth2] |
Collaborator
There was a problem hiding this comment.
omniauth_providers: [:facebook, :google_oauth2]
| # Devise will use the `secret_key_base` as its `secret_key` | ||
| # by default. You can change it below and use your own secret key. | ||
| config.secret_key = "e8c70e82c9b9640a75d868a18103e7cbb462541b07c13d2a9859a5831bb88cbc5f99dc172cecdeb6fc2135da61cd63bd59f73ec1522b4b71eeedf2fd803a519f" | ||
| config.omniauth :facebook, "1429323677136476", "efca88e3cddd7da97e3d0deea2d4cbe9", {scope: "email"} |
Collaborator
There was a problem hiding this comment.
Bạn tìm hiểu "Rails Environment Variables" rồi áp dụng vào đây nhé
| config.secret_key = "e8c70e82c9b9640a75d868a18103e7cbb462541b07c13d2a9859a5831bb88cbc5f99dc172cecdeb6fc2135da61cd63bd59f73ec1522b4b71eeedf2fd803a519f" | ||
| config.omniauth :facebook, "1429323677136476", "efca88e3cddd7da97e3d0deea2d4cbe9", {scope: "email"} | ||
|
|
||
| config.omniauth :google_oauth2, "101518049891-38cfc85q5fc402blp6kt1lac8ogq8bgv.apps.googleusercontent.com", "X-wbChTGdJwaxfDnoGGpMhVp", skip_jwt: true |
Collaborator
|
commented |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.