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 #1078

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

Done #1078

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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.sqlite3
*.log
tmp/Gemfile.lock
tmp/Gemfile.lock
.env
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ gem 'coffee-rails', '~> 4.1.0'

gem 'thin'

gem 'omniauth'
gem 'omniauth-facebook'
gem 'dotenv-rails'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
Expand Down
30 changes: 29 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,26 @@ GEM
concurrent-ruby (1.1.5)
crass (1.0.5)
daemons (1.3.1)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
erubis (2.7.0)
eventmachine (1.2.7)
execjs (2.7.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
ffi (1.11.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
hashie (4.1.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jwt (2.2.1)
loofah (2.3.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -73,9 +81,26 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.11.3)
multi_json (1.14.1)
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.4.0)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
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 (6.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1)
omniauth (~> 1.9)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down Expand Up @@ -153,7 +178,10 @@ PLATFORMS
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
jquery-rails
omniauth
omniauth-facebook
pry
rails (~> 5.0)
sass-rails (~> 5.0)
Expand All @@ -164,4 +192,4 @@ DEPENDENCIES
uglifier (>= 1.3.0)

BUNDLED WITH
2.0.1
2.1.4
22 changes: 22 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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

binding.pry

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/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
11 changes: 11 additions & 0 deletions app/views/welcome/home.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
<%# 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
54 changes: 1 addition & 53 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,58 +1,6 @@
Rails.application.routes.draw do
root 'welcome#home'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
get '/auth/facebook/callback' => 'sessions#create'

# You can have the root of your site routed with "root"
# root 'welcome#index'

# Example of regular route:
# get 'products/:id' => 'catalog#view'

# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products

# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end

# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end

# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end

# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable

# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
10 changes: 10 additions & 0 deletions db/migrate/20200516134116_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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
end
end
end
10 changes: 8 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,13 @@
#
# It's strongly recommended that you check this file into your version control system.

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

create_table "users", force: :cascade do |t|
t.string "name"
t.string "email"
t.string "image"
t.string "uid"
end

end
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/application.js?type=application/javascript&id=3f80283fc6bf40d87d83d22f00e6a86f7f70869d3d722ddc8e19044860852107:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[o:Set:
@hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"9file-digest://app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI")file-digest://app/assets/stylesheets;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�/home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js?type=application/javascript&pipeline=self&id=e99d41276d846c7b3820f34296d30d564709e94333b00618f1da9b148a4bb3c8:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[o:Set:
@hash}#I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"8file-digest://app/assets/javascripts/application.js;TTI"$file-digest://app/assets/images;TTI"+file-digest://app/assets/images/jquery;TTI")file-digest://app/assets/javascripts;TTI"0file-digest://app/assets/javascripts/jquery;TTI")file-digest://app/assets/stylesheets;TTI"0file-digest://app/assets/stylesheets/jquery;TTI"hfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts;TTI"ofile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery;TTI"rfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTI"/file-digest://app/assets/images/jquery_ujs;TTI"4file-digest://app/assets/javascripts/jquery_ujs;TTI"4file-digest://app/assets/stylesheets/jquery_ujs;TTI"sfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs;TTI"vfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js;TTI"/file-digest://app/assets/images/turbolinks;TTI"4file-digest://app/assets/javascripts/turbolinks;TTI"4file-digest://app/assets/stylesheets/turbolinks;TTI"sfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/turbolinks;TTI"efile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts;TTI"pfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts/turbolinks;TTI"cfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled;TTI"nfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled/turbolinks;TTI"jfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts;TTI"ufile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks;TTI"xfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js;TTF
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"xfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=90ef4498731b9b2ea298999837038a8cbe33d8f05d342ff669472b415f8e0f0d:ET
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,2 @@
[o:Set:
@hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"?processors:type=text/css&file_type=text/css&pipeline=debug;TTI"9file-digest://app/assets/stylesheets/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI")file-digest://app/assets/stylesheets;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%C6������ܦ�M=��Qu���/�,"c�5u
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[o:Set:
@hash}$I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"[processors:type=application/javascript&file_type=application/javascript&pipeline=debug;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"rfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTI"vfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js;TTI"xfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js;TTI"$file-digest://app/assets/images;TTI"+file-digest://app/assets/images/jquery;TTI")file-digest://app/assets/javascripts;TTI"0file-digest://app/assets/javascripts/jquery;TTI")file-digest://app/assets/stylesheets;TTI"0file-digest://app/assets/stylesheets/jquery;TTI"hfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts;TTI"ofile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery;TTI"/file-digest://app/assets/images/jquery_ujs;TTI"4file-digest://app/assets/javascripts/jquery_ujs;TTI"4file-digest://app/assets/stylesheets/jquery_ujs;TTI"sfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs;TTI"/file-digest://app/assets/images/turbolinks;TTI"4file-digest://app/assets/javascripts/turbolinks;TTI"4file-digest://app/assets/stylesheets/turbolinks;TTI"sfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/turbolinks;TTI"efile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts;TTI"pfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts/turbolinks;TTI"cfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled;TTI"nfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled/turbolinks;TTI"jfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts;TTI"ufile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%Ѱč@�����6H�uZoX�Z�gbh0W��V
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[o:Set:
@hash} I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"9file-digest://app/assets/stylesheets/application.css;TTI")file-digest://app/assets/stylesheets;TTF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�/home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js?type=application/javascript&pipeline=self&id=c2ebdefe9a361c412dd754c1a53cac2f418544f61e99096890ca89ca4122a2c0:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%xJ�g&k��"��U���m��X�V�;Fj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"}app/assets/stylesheets/application.css?type=text/css&id=53060a805d70913106829dd3ae307f1405a8274054ff215cb124cc84c6874e5b:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%ó�n���x���|��b�[ģ��Y��xF�
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
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 @@
"%��B�����șo�$'�A�d��L���xR�U
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=b06b8170a6e6378c9377318b02e4ec45c52b128c9a13287cf26c415db113f412: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"rfile-digest:///home/igutwins/.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 @@
"%���/�.?Ȳ�0-H��qN�c2���{M�rb�
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=921092a9f8161de95f00976a85ef33d744fba860cb8d6913b503ee60a590c206:ET
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,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:///home/igutwins/.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,2 @@
[o:Set:
@hash}$I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"rfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTI"vfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js;TTI"xfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js;TTI"$file-digest://app/assets/images;TTI"+file-digest://app/assets/images/jquery;TTI")file-digest://app/assets/javascripts;TTI"0file-digest://app/assets/javascripts/jquery;TTI")file-digest://app/assets/stylesheets;TTI"0file-digest://app/assets/stylesheets/jquery;TTI"hfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts;TTI"ofile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery;TTI"/file-digest://app/assets/images/jquery_ujs;TTI"4file-digest://app/assets/javascripts/jquery_ujs;TTI"4file-digest://app/assets/stylesheets/jquery_ujs;TTI"sfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs;TTI"/file-digest://app/assets/images/turbolinks;TTI"4file-digest://app/assets/javascripts/turbolinks;TTI"4file-digest://app/assets/stylesheets/turbolinks;TTI"sfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/turbolinks;TTI"efile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts;TTI"pfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts/turbolinks;TTI"cfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled;TTI"nfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled/turbolinks;TTI"jfile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts;TTI"ufile-digest:///home/igutwins/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks;TTF
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=db256803560f36deb2d98f46edf516768c71fb3093dd51394703cbc641b354eb:ET
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%�d�-�K���`���8Y��3�͹/Y����a~K
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�/home/igutwins/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js?type=application/javascript&pipeline=self&id=706d9aa41cb60e6cd023ec97b655ad62685c627d161f8b029410b3eecb577962:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%�~��2%�a�5�p���L�Je5�-,$�o\2
Binary file not shown.