Skip to content
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

Done #1089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #1089

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.sqlite3
*.log
.env
tmp/Gemfile.lock
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ gem 'thin'
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

gem 'omniauth', '~> 1.9.1'
gem 'omniauth-facebook'
gem 'dotenv-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
Expand Down
98 changes: 65 additions & 33 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,74 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
builder (3.2.3)
byebug (11.0.1)
coderay (1.1.2)
builder (3.2.4)
byebug (11.1.3)
coderay (1.1.3)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.5)
crass (1.0.5)
concurrent-ruby (1.1.8)
crass (1.0.6)
daemons (1.3.1)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
erubis (2.7.0)
eventmachine (1.2.7)
execjs (2.7.0)
ffi (1.11.1)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords
faraday-net_http (1.0.1)
ffi (1.14.2)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.6.0)
hashie (4.1.0)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
jquery-rails (4.3.5)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
loofah (2.3.1)
jwt (2.2.2)
loofah (2.9.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (0.9.2)
method_source (1.0.0)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
nio4r (2.4.0)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
minitest (5.14.4)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.5.5)
nokogiri (1.11.1-x86_64-darwin)
racc (~> 1.4)
oauth2 (1.4.4)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-facebook (8.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.7.1)
oauth2 (~> 1.4)
omniauth (>= 1.9, < 3)
pry (0.14.0)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.5.2)
rack (2.2.3)
rack-test (0.6.3)
rack (>= 1.0)
Expand All @@ -97,18 +125,19 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.3)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
rake (13.0.3)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
ruby2_keywords (0.0.4)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand All @@ -120,40 +149,43 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
spring (2.1.0)
spring (2.1.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thin (1.7.2)
thin (1.8.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
thor (0.20.3)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.9)
turbolinks (5.2.0)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.5)
tzinfo (1.2.9)
thread_safe (~> 0.1)
uglifier (4.1.20)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
ruby
x86_64-darwin-19

DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
jquery-rails
omniauth (~> 1.9.1)
omniauth-facebook
pry
rails (~> 5.0)
sass-rails (~> 5.0)
Expand All @@ -164,4 +196,4 @@ DEPENDENCIES
uglifier (>= 1.3.0)

BUNDLED WITH
2.0.1
2.2.7
3 changes: 3 additions & 0 deletions app/assets/javascripts/sessions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/users.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sessions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/users.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
21 changes: 21 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class SessionsController < ApplicationController
def create
@user = User.find_or_create_by(uid: auth['uid']) do |u|
u.name = auth['info']['name']
u.email = auth['info']['email']
u.image = auth['info']['image']
end

session[:user_id] = @user.id

render 'welcome/home'
end



private

def auth
request.env['omniauth.auth']
end
end
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class UsersController < ApplicationController
end
2 changes: 2 additions & 0 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SessionsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module UsersHelper
end
3 changes: 3 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ApplicationRecord
end
9 changes: 8 additions & 1 deletion app/views/welcome/home.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<%# Add the Facebook login link here %>
<% if session[:user_id] %>
<h1><%= @user.name %></h1>
<h2>Email: <%= @user.email %></h2>
<h2>Facebook UID: <%= @user.uid %></h2>
<img src="<%= @user.image %>">
<% else %>
<%= link_to('Log in with Facebook!', '/auth/facebook') %>
<% end %>
3 changes: 3 additions & 0 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
end
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Rails.application.routes.draw do
resources :users
root 'welcome#home'

get '/auth/facebook/callback' => 'sessions#create'


# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20210303182612_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :image
t.string :uid

t.timestamps
end
end
end
12 changes: 10 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand All @@ -11,6 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 0) do
ActiveRecord::Schema.define(version: 20210303182612) do

create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "image"
t.string "uid"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
7 changes: 7 additions & 0 deletions test/controllers/sessions_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class SessionsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=1b9d794665e0788b2ab1f2a852a3ee118c3c8ca9510a8efa02ecbafc9c663307:ET
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%�~��2%�a�5�p���L�Je5�-,$�o\2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%Ѱč@�����6H�uZoX�Z�gbh0W��V
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/stylesheets/users.scss?type=text/css&pipeline=self&id=20ce0a786641ed86006e0242830dcd5d5b3a93f930334ad97de89062328a8de8:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�/Users/andyaguilar/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js?type=application/javascript&pipeline=self&id=71bbfd5f6a883cb8f209323f7c75ea8230c94a3db76cb08a7eb76b29d26d97ad:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/stylesheets/application.css?type=text/css&pipeline=debug&id=4d6e3dcb905a02d15302e5f9cfa3879a0efb833ce7156c9bb64092a3be029de2:ET
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"}app/assets/stylesheets/application.css?type=text/css&id=dfd80e98b9715ce9a90e2a4f210f4e1a6c744c35f2b231aa4b25fdc7dbf66013:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/stylesheets/users.scss?type=text/css&pipeline=self&id=64a6984ec4ca36bfb0fd1a92a4ba0ff9468856c90522a8ca0d3c4b995b391823:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[o:Set:
@hash}
I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"vfile-digest:///Users/andyaguilar/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.4.0/vendor/assets/javascripts/jquery.js;TTF
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[o:Set:
@hash}
I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"zfile-digest:///Users/andyaguilar/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%uW��l��j��Z� xU��>�?]��pc��s
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"%�y �&��B�"��H���
m)��,�%�܎Zt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%�d�-�K���`���8Y��3�͹/Y����a~K
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/javascripts/sessions.coffee?type=application/javascript&pipeline=self&id=e291a60062e49ee389c517d7ec355e5438eb5bb17278934c80185c6898fabbcd:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[o:Set:
@hash}
I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"vfile-digest:///Users/andyaguilar/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�/Users/andyaguilar/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js?type=application/javascript&pipeline=self&id=89fd67ed4b77e1e43f47b597699fccdce24897e98692b72dad44f8154095fc88:ET
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%��B�����șo�$'�A�d��L���xR�U
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�/Users/andyaguilar/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js?type=application/javascript&pipeline=self&id=b6f62fbc32e4cf98f31f13d38118cb905e8bf0ab360fa56c7f2cc6dd479ec127:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/javascripts/users.coffee?type=application/javascript&pipeline=self&id=6ad8c62d4ccaa40e297ffa676012da89bd5fd016ca691f523c2f543226755beb:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=debug&id=48539a08a7483cee73c855153bdf3802e1f49f9027817c9c2837a2800a8132b9:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=3efd1616b24b7a5d3269da14a7f5b0dda3d6047269a77142e6858e38d7dcbd46:ET
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%ó�n���x���|��b�[ģ��Y��xF�
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"}app/assets/stylesheets/application.css?type=text/css&id=4879296054ab5057c594fa69f2e1eacb950fd99e50b1330eaaf3f462bc497a81:ET
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%����`���/F� �� ���Y(}H�R�
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%C6������ܦ�M=��Qu���/�,"c�5u
Loading