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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Done #1080

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
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ gem 'turbolinks'
# gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
# gem 'sdoc', '~> 0.4.0', group: :doc

gem 'dotenv-rails'
gem 'omniauth-google-oauth2'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand Down
31 changes: 30 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,28 @@ 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.8)
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-google-oauth2 (0.8.0)
jwt (>= 2.0)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.6)
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 +180,9 @@ PLATFORMS
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
jquery-rails
omniauth-google-oauth2
pry
rails (~> 5.0)
sass-rails (~> 5.0)
Expand All @@ -164,4 +193,4 @@ DEPENDENCIES
uglifier (>= 1.3.0)

BUNDLED WITH
2.0.1
2.1.4
19 changes: 19 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class SessionsController < ApplicationController
def create
# binding.pry
@user = User.find_or_create_by(email: auth['info']['email']) do |u|
u.name = auth['info']['name']
u.email = auth['info']['email']
end

session[:user_id] = @user.id

render 'welcome/home'
end

private

def auth
request.env['omniauth.auth']
end
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
7 changes: 7 additions & 0 deletions 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>
<% else %>
<%= link_to "Sign in with Google", '/auth/google_oauth2' %>
<% 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 :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET']
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Rails.application.routes.draw do
root 'welcome#home'

get '/auth/google_oauth2/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
10 changes: 10 additions & 0 deletions db/migrate/20200707175159_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.timestamps
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: 20200707175159) do

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

end
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"wfile-digest:///Users/mbeebe/.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,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 @@
"%C6������ܦ�M=��Qu���/�,"c�5u
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,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"ufile-digest:///Users/mbeebe/.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"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"gfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts;TTI"nfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery;TTI"qfile-digest:///Users/mbeebe/.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"rfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs;TTI"ufile-digest:///Users/mbeebe/.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"rfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/turbolinks;TTI"dfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts;TTI"ofile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts/turbolinks;TTI"bfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled;TTI"mfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled/turbolinks;TTI"ifile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts;TTI"tfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks;TTI"wfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js;TTF
Binary file not shown.
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=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,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"qfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTI"ufile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js;TTI"wfile-digest:///Users/mbeebe/.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"gfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts;TTI"nfile-digest:///Users/mbeebe/.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"rfile-digest:///Users/mbeebe/.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"rfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/turbolinks;TTI"dfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts;TTI"ofile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts/turbolinks;TTI"bfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled;TTI"mfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled/turbolinks;TTI"ifile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts;TTI"tfile-digest:///Users/mbeebe/.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"�/Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js?type=application/javascript&pipeline=self&id=bcde772a52ab444e5d184c4f8d16b243bfd91e85ea8324a19db02954352c147b:ET
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&pipeline=self&id=7c82d48f083d640c3fd351ba1c343f72d6cfb0bf9e104a5b7dca95314f4ddc34: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,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
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=8a3092cd1cd565180f09286c1e1bb6be2a464d88f59d18da98b4756bb7520b5c: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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"}app/assets/stylesheets/application.css?type=text/css&id=3bca9b760164321d4a09c8aa4477aee9cff4fa8142f88311531698d3b3d96754:ET
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 @@
"%�d�-�K���`���8Y��3�͹/Y����a~K
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=37137b5b565108e1a90907ae85625d9a09ede36a3b286a0f6a6beaaaf5cd684a:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I"�app/assets/javascripts/application.js?type=application/javascript&id=0f18fdf5de84167e33df225b0318436e5d4470d04cfcacb6d8869c4e37a20521:ET
Binary file not shown.
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 @@
I"�/Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks.js?type=application/javascript&pipeline=self&id=5ec9c39f39267781f7bd5d7847967a52cd41e68be483992f058159aa8c621ff2:ET
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,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"qfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTI"ufile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery_ujs.js;TTI"wfile-digest:///Users/mbeebe/.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"gfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts;TTI"nfile-digest:///Users/mbeebe/.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"rfile-digest:///Users/mbeebe/.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"rfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/turbolinks;TTI"dfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts;TTI"ofile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/coffee-rails-4.1.1/lib/assets/javascripts/turbolinks;TTI"bfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled;TTI"mfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/actioncable-5.0.7.2/lib/assets/compiled/turbolinks;TTI"ifile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts;TTI"tfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/turbolinks-source-5.2.0/lib/assets/javascripts/turbolinks;TTF
Binary file not shown.
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 @@
I"�/Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js?type=application/javascript&pipeline=self&id=df90855f7dcffde71cc66f596812de0490a2c559265e82436c52735bf63e1916:ET
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&pipeline=debug&id=4455fd7625f6b2d4679bc9137aff1c36b40a853caa7056fe7b1529096e932596:ET
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,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"qfile-digest:///Users/mbeebe/.rvm/gems/ruby-2.6.1/gems/jquery-rails-4.3.5/vendor/assets/javascripts/jquery.js;TTF