Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
warm_city
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mykhailo Makohin
warm_city
Commits
f0fb8ffd
Commit
f0fb8ffd
authored
Sep 02, 2019
by
Mykhailo Makohin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix facebook registration
parent
257b84a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
omniauth_callbacks_controller.rb
app/controllers/users/omniauth_callbacks_controller.rb
+2
-1
user.rb
app/models/user.rb
+5
-0
devise.rb
config/initializers/devise.rb
+1
-6
No files found.
app/controllers/users/omniauth_callbacks_controller.rb
View file @
f0fb8ffd
class
Users
::
OmniauthCallbacksController
<
Devise
::
OmniauthCallbacksController
def
facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user
=
User
.
from_omniauth
(
request
.
env
[
"omniauth.auth"
])
if
@user
.
persisted?
sign_in_and_redirect
@user
,
event: :authentication
sign_in_and_redirect
@user
,
event: :authentication
#this will throw if @user is not activated
set_flash_message
(
:notice
,
:success
,
kind:
"Facebook"
)
if
is_navigational_format?
else
session
[
"devise.facebook_data"
]
=
request
.
env
[
"omniauth.auth"
]
...
...
app/models/user.rb
View file @
f0fb8ffd
...
...
@@ -4,6 +4,11 @@ class User < ApplicationRecord
:recoverable
,
:rememberable
,
:omniauthable
,
omniauth_providers:
[
:facebook
,
:google_oauth2
]
before_create
do
self
.
email
=
'example123@gmail.com'
if
email
.
nil?
end
validates
:email
,
presence:
false
def
self
.
new_with_session
(
params
,
session
)
super
.
tap
do
|
user
|
...
...
config/initializers/devise.rb
View file @
f0fb8ffd
...
...
@@ -26,12 +26,7 @@ Devise.setup do |config|
config
.
omniauth
:facebook
,
"2429624190692901"
,
"03da24c1517b0bfa4acc70852f61fb60"
,
callback_url:
"http://localhost:3000/users/auth/facebook/callback"
,
scope:
'public_profile,email'
,
info_fields:
'email,first_name,last_name,gender,birthday,location,picture'
,
client_options:
{
site:
'https://graph.facebook.com/v2.11'
,
authorize_url:
"https://www.facebook.com/v2.11/dialog/oauth"
}
scope:
'email'
,
info_fields:
'email,name'
config
.
omniauth
:google_oauth2
,
"444952886435-8s76oeuc53otc8q84jork9mq4php7e7t.apps.googleusercontent.com"
,
"vfJkP71fOkfDKVYa3RgXR3lW"
,
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment