omniauth-slooob 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/issue_template.md +14 -0
- data/.github/pull_request_template.md +21 -0
- data/.gitignore +22 -0
- data/.travis.yml +3 -0
- data/CHANGELOG.md +9 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +7 -0
- data/LICENSE +21 -0
- data/README.md +301 -0
- data/Rakefile +15 -0
- data/examples/omniauth.rb +31 -0
- data/examples/rails_example/.gitignore +27 -0
- data/examples/rails_example/Gemfile +54 -0
- data/examples/rails_example/README.md +24 -0
- data/examples/rails_example/Rakefile +6 -0
- data/examples/rails_example/app/assets/config/manifest.js +3 -0
- data/examples/rails_example/app/assets/images/.keep +0 -0
- data/examples/rails_example/app/assets/javascripts/application.js +15 -0
- data/examples/rails_example/app/assets/javascripts/books.coffee +3 -0
- data/examples/rails_example/app/assets/javascripts/cable.js +13 -0
- data/examples/rails_example/app/assets/javascripts/channels/.keep +0 -0
- data/examples/rails_example/app/assets/javascripts/sessions.coffee +3 -0
- data/examples/rails_example/app/assets/stylesheets/application.css +15 -0
- data/examples/rails_example/app/assets/stylesheets/books.scss +3 -0
- data/examples/rails_example/app/assets/stylesheets/scaffolds.scss +84 -0
- data/examples/rails_example/app/assets/stylesheets/sessions.scss +3 -0
- data/examples/rails_example/app/channels/application_cable/channel.rb +4 -0
- data/examples/rails_example/app/channels/application_cable/connection.rb +4 -0
- data/examples/rails_example/app/controllers/application_controller.rb +10 -0
- data/examples/rails_example/app/controllers/books_controller.rb +74 -0
- data/examples/rails_example/app/controllers/concerns/.keep +0 -0
- data/examples/rails_example/app/controllers/sessions_controller.rb +16 -0
- data/examples/rails_example/app/helpers/application_helper.rb +2 -0
- data/examples/rails_example/app/helpers/books_helper.rb +2 -0
- data/examples/rails_example/app/helpers/sessions_helper.rb +2 -0
- data/examples/rails_example/app/jobs/application_job.rb +2 -0
- data/examples/rails_example/app/mailers/application_mailer.rb +4 -0
- data/examples/rails_example/app/models/application_record.rb +3 -0
- data/examples/rails_example/app/models/book.rb +2 -0
- data/examples/rails_example/app/models/concerns/.keep +0 -0
- data/examples/rails_example/app/models/user.rb +12 -0
- data/examples/rails_example/app/views/books/_book.json.jbuilder +2 -0
- data/examples/rails_example/app/views/books/_form.html.erb +17 -0
- data/examples/rails_example/app/views/books/edit.html.erb +6 -0
- data/examples/rails_example/app/views/books/index.html.erb +25 -0
- data/examples/rails_example/app/views/books/index.json.jbuilder +1 -0
- data/examples/rails_example/app/views/books/new.html.erb +5 -0
- data/examples/rails_example/app/views/books/show.html.erb +4 -0
- data/examples/rails_example/app/views/books/show.json.jbuilder +1 -0
- data/examples/rails_example/app/views/layouts/application.html.erb +19 -0
- data/examples/rails_example/app/views/layouts/mailer.html.erb +13 -0
- data/examples/rails_example/app/views/layouts/mailer.text.erb +1 -0
- data/examples/rails_example/bin/bundle +3 -0
- data/examples/rails_example/bin/rails +4 -0
- data/examples/rails_example/bin/rake +4 -0
- data/examples/rails_example/bin/setup +38 -0
- data/examples/rails_example/bin/update +29 -0
- data/examples/rails_example/bin/yarn +11 -0
- data/examples/rails_example/config.ru +5 -0
- data/examples/rails_example/config/application.rb +18 -0
- data/examples/rails_example/config/boot.rb +3 -0
- data/examples/rails_example/config/cable.yml +10 -0
- data/examples/rails_example/config/database.yml +25 -0
- data/examples/rails_example/config/environment.rb +5 -0
- data/examples/rails_example/config/environments/development.rb +54 -0
- data/examples/rails_example/config/environments/production.rb +91 -0
- data/examples/rails_example/config/environments/test.rb +42 -0
- data/examples/rails_example/config/initializers/application_controller_renderer.rb +6 -0
- data/examples/rails_example/config/initializers/assets.rb +14 -0
- data/examples/rails_example/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/rails_example/config/initializers/config.rb +36 -0
- data/examples/rails_example/config/initializers/cookies_serializer.rb +5 -0
- data/examples/rails_example/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/rails_example/config/initializers/inflections.rb +16 -0
- data/examples/rails_example/config/initializers/mime_types.rb +4 -0
- data/examples/rails_example/config/initializers/omniauth.rb +3 -0
- data/examples/rails_example/config/initializers/wrap_parameters.rb +14 -0
- data/examples/rails_example/config/locales/en.yml +33 -0
- data/examples/rails_example/config/puma.rb +56 -0
- data/examples/rails_example/config/routes.rb +10 -0
- data/examples/rails_example/config/secrets.yml +32 -0
- data/examples/rails_example/config/settings.yml +1 -0
- data/examples/rails_example/config/settings/development.yml +3 -0
- data/examples/rails_example/config/settings/production.yml +3 -0
- data/examples/rails_example/config/settings/test.yml +3 -0
- data/examples/rails_example/db/migrate/20170827120704_create_books.rb +8 -0
- data/examples/rails_example/db/migrate/20170827122351_create_users.rb +11 -0
- data/examples/rails_example/db/schema.rb +28 -0
- data/examples/rails_example/db/seeds.rb +7 -0
- data/examples/rails_example/lib/assets/.keep +0 -0
- data/examples/rails_example/lib/tasks/.keep +0 -0
- data/examples/rails_example/log/.keep +0 -0
- data/examples/rails_example/package.json +5 -0
- data/examples/rails_example/public/404.html +67 -0
- data/examples/rails_example/public/422.html +67 -0
- data/examples/rails_example/public/500.html +66 -0
- data/examples/rails_example/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/rails_example/public/apple-touch-icon.png +0 -0
- data/examples/rails_example/public/favicon.ico +0 -0
- data/examples/rails_example/public/robots.txt +1 -0
- data/examples/rails_example/test/application_system_test_case.rb +5 -0
- data/examples/rails_example/test/controllers/.keep +0 -0
- data/examples/rails_example/test/controllers/books_controller_test.rb +48 -0
- data/examples/rails_example/test/controllers/sessions_controller_test.rb +9 -0
- data/examples/rails_example/test/fixtures/.keep +0 -0
- data/examples/rails_example/test/fixtures/books.yml +11 -0
- data/examples/rails_example/test/fixtures/files/.keep +0 -0
- data/examples/rails_example/test/fixtures/users.yml +9 -0
- data/examples/rails_example/test/helpers/.keep +0 -0
- data/examples/rails_example/test/integration/.keep +0 -0
- data/examples/rails_example/test/mailers/.keep +0 -0
- data/examples/rails_example/test/models/.keep +0 -0
- data/examples/rails_example/test/models/book_test.rb +7 -0
- data/examples/rails_example/test/models/user_test.rb +7 -0
- data/examples/rails_example/test/system/.keep +0 -0
- data/examples/rails_example/test/system/books_test.rb +9 -0
- data/examples/rails_example/test/test_helper.rb +9 -0
- data/examples/rails_example/vendor/.keep +0 -0
- data/lib/omniauth-slooob.rb +1 -0
- data/lib/omniauth/slooob.rb +1 -0
- data/lib/omniauth/slooob/version.rb +7 -0
- data/lib/omniauth/strategies/slooob.rb +95 -0
- data/omniauth-slooob.gemspec +28 -0
- data/test/test.rb +239 -0
- metadata +265 -0
data/Rakefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require 'rake'
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
|
|
7
|
+
desc 'Default: run unit tests.'
|
|
8
|
+
task default: :test
|
|
9
|
+
|
|
10
|
+
desc 'Test omniauth-slooob gem.'
|
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
|
12
|
+
t.libs << 'lib'
|
|
13
|
+
t.pattern = 'test/test.rb'
|
|
14
|
+
t.verbose = true
|
|
15
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Slooob OAuth2 docs. Make sure you are familiar with all the options before attempting to configure this gem.
|
|
2
|
+
# https://developer.slooob.com/docs/api/identity/v1
|
|
3
|
+
|
|
4
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
|
5
|
+
# Default usage
|
|
6
|
+
provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET']
|
|
7
|
+
|
|
8
|
+
# # Default options
|
|
9
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'email public', incremental_authorization: false, image_size: 'raw'
|
|
10
|
+
#
|
|
11
|
+
# # Image Sizes
|
|
12
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], image_size: 'raw' # => 800x800
|
|
13
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], image_size: 'big' # => 350x350
|
|
14
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], image_size: 'medium' # => 100x100
|
|
15
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], image_size: 'small' # => 75x75
|
|
16
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], image_size: 'tiny' # => 50x50
|
|
17
|
+
#
|
|
18
|
+
# # Incremental Authorization
|
|
19
|
+
# # To only specify the scopes that your application has not been authorized for by a given user, enable `incremental_authorization`.
|
|
20
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], incremental_authorization: true
|
|
21
|
+
#
|
|
22
|
+
# # More Scopes
|
|
23
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'private' # => adds private information about the user to the returned hash
|
|
24
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'modify' # => grants permission to use the Slooob API v1 for a given user
|
|
25
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'ads' # => grants permission to use the Ads API v1 for a given user
|
|
26
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'cloud' # => grants permission to use the Cloud API v1 for a given user
|
|
27
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'messaging' # => grants permission to use the Messaging API v1 for a given user
|
|
28
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'ocode' # => grants permission to use the Ocode API v1 for a given user
|
|
29
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'pages' # => grants permission to use the Pages API v1 for a given user
|
|
30
|
+
# provider :slooob, ENV['SLOOOB_KEY'], ENV['SLOOOB_SECRET'], scope: 'payments' # => grants permission to use the Payments API v1 for a given user
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
2
|
+
#
|
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
|
6
|
+
|
|
7
|
+
# Ignore bundler config.
|
|
8
|
+
/.bundle
|
|
9
|
+
|
|
10
|
+
# Ignore the default SQLite database.
|
|
11
|
+
/db/*.sqlite3
|
|
12
|
+
/db/*.sqlite3-journal
|
|
13
|
+
|
|
14
|
+
# Ignore all logfiles and tempfiles.
|
|
15
|
+
/log/*
|
|
16
|
+
/tmp/*
|
|
17
|
+
!/log/.keep
|
|
18
|
+
!/tmp/.keep
|
|
19
|
+
|
|
20
|
+
/node_modules
|
|
21
|
+
/yarn-error.log
|
|
22
|
+
|
|
23
|
+
.byebug_history
|
|
24
|
+
|
|
25
|
+
config/settings.local.yml
|
|
26
|
+
config/settings/*.local.yml
|
|
27
|
+
config/environments/*.local.yml
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
git_source(:github) do |repo_name|
|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
|
5
|
+
"https://github.com/#{repo_name}.git"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
gem 'omniauth-slooob'
|
|
10
|
+
gem 'config'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
|
14
|
+
gem 'rails', '~> 5.1.3'
|
|
15
|
+
# Use sqlite3 as the database for Active Record
|
|
16
|
+
gem 'sqlite3'
|
|
17
|
+
# Use Puma as the app server
|
|
18
|
+
gem 'puma', '~> 3.7'
|
|
19
|
+
# Use SCSS for stylesheets
|
|
20
|
+
gem 'sass-rails', '~> 5.0'
|
|
21
|
+
# Use Uglifier as compressor for JavaScript assets
|
|
22
|
+
gem 'uglifier', '>= 1.3.0'
|
|
23
|
+
# See https://github.com/rails/execjs#readme for more supported runtimes
|
|
24
|
+
# gem 'therubyracer', platforms: :ruby
|
|
25
|
+
|
|
26
|
+
# Use CoffeeScript for .coffee assets and views
|
|
27
|
+
gem 'coffee-rails', '~> 4.2'
|
|
28
|
+
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
|
29
|
+
gem 'turbolinks', '~> 5'
|
|
30
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
|
31
|
+
gem 'jbuilder', '~> 2.5'
|
|
32
|
+
# Use Redis adapter to run Action Cable in production
|
|
33
|
+
# gem 'redis', '~> 3.0'
|
|
34
|
+
# Use ActiveModel has_secure_password
|
|
35
|
+
# gem 'bcrypt', '~> 3.1.7'
|
|
36
|
+
|
|
37
|
+
# Use Capistrano for deployment
|
|
38
|
+
# gem 'capistrano-rails', group: :development
|
|
39
|
+
|
|
40
|
+
group :development, :test do
|
|
41
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
|
42
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
|
43
|
+
# Adds support for Capybara system testing and selenium driver
|
|
44
|
+
gem 'capybara', '~> 2.13'
|
|
45
|
+
gem 'selenium-webdriver'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
group :development do
|
|
49
|
+
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
|
50
|
+
gem 'web-console', '>= 3.3.0'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
|
54
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
|
|
5
|
+
// vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require rails-ujs
|
|
14
|
+
//= require turbolinks
|
|
15
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
|
3
|
+
//
|
|
4
|
+
//= require action_cable
|
|
5
|
+
//= require_self
|
|
6
|
+
//= require_tree ./channels
|
|
7
|
+
|
|
8
|
+
(function() {
|
|
9
|
+
this.App || (this.App = {});
|
|
10
|
+
|
|
11
|
+
App.cable = ActionCable.createConsumer();
|
|
12
|
+
|
|
13
|
+
}).call(this);
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
|
11
|
+
* It is generally better to create a new file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
body {
|
|
2
|
+
background-color: #fff;
|
|
3
|
+
color: #333;
|
|
4
|
+
margin: 33px;
|
|
5
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
6
|
+
font-size: 13px;
|
|
7
|
+
line-height: 18px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
p, ol, ul, td {
|
|
11
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
12
|
+
font-size: 13px;
|
|
13
|
+
line-height: 18px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
pre {
|
|
17
|
+
background-color: #eee;
|
|
18
|
+
padding: 10px;
|
|
19
|
+
font-size: 11px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
a {
|
|
23
|
+
color: #000;
|
|
24
|
+
|
|
25
|
+
&:visited {
|
|
26
|
+
color: #666;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:hover {
|
|
30
|
+
color: #fff;
|
|
31
|
+
background-color: #000;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
th {
|
|
36
|
+
padding-bottom: 5px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
td {
|
|
40
|
+
padding: 0 5px 7px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
div {
|
|
44
|
+
&.field, &.actions {
|
|
45
|
+
margin-bottom: 10px;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#notice {
|
|
50
|
+
color: green;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.field_with_errors {
|
|
54
|
+
padding: 2px;
|
|
55
|
+
background-color: red;
|
|
56
|
+
display: table;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#error_explanation {
|
|
60
|
+
width: 450px;
|
|
61
|
+
border: 2px solid red;
|
|
62
|
+
padding: 7px 7px 0;
|
|
63
|
+
margin-bottom: 20px;
|
|
64
|
+
background-color: #f0f0f0;
|
|
65
|
+
|
|
66
|
+
h2 {
|
|
67
|
+
text-align: left;
|
|
68
|
+
font-weight: bold;
|
|
69
|
+
padding: 5px 5px 5px 15px;
|
|
70
|
+
font-size: 12px;
|
|
71
|
+
margin: -7px -7px 0;
|
|
72
|
+
background-color: #c00;
|
|
73
|
+
color: #fff;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
ul li {
|
|
77
|
+
font-size: 12px;
|
|
78
|
+
list-style: square;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
label {
|
|
83
|
+
display: block;
|
|
84
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
class BooksController < ApplicationController
|
|
2
|
+
before_action :set_book, only: [:show, :edit, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
# GET /books
|
|
5
|
+
# GET /books.json
|
|
6
|
+
def index
|
|
7
|
+
@books = Book.all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# GET /books/1
|
|
11
|
+
# GET /books/1.json
|
|
12
|
+
def show
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# GET /books/new
|
|
16
|
+
def new
|
|
17
|
+
@book = Book.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# GET /books/1/edit
|
|
21
|
+
def edit
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# POST /books
|
|
25
|
+
# POST /books.json
|
|
26
|
+
def create
|
|
27
|
+
@book = Book.new(book_params)
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
if @book.save
|
|
31
|
+
format.html { redirect_to @book, notice: 'Book was successfully created.' }
|
|
32
|
+
format.json { render :show, status: :created, location: @book }
|
|
33
|
+
else
|
|
34
|
+
format.html { render :new }
|
|
35
|
+
format.json { render json: @book.errors, status: :unprocessable_entity }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# PATCH/PUT /books/1
|
|
41
|
+
# PATCH/PUT /books/1.json
|
|
42
|
+
def update
|
|
43
|
+
respond_to do |format|
|
|
44
|
+
if @book.update(book_params)
|
|
45
|
+
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
|
|
46
|
+
format.json { render :show, status: :ok, location: @book }
|
|
47
|
+
else
|
|
48
|
+
format.html { render :edit }
|
|
49
|
+
format.json { render json: @book.errors, status: :unprocessable_entity }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# DELETE /books/1
|
|
55
|
+
# DELETE /books/1.json
|
|
56
|
+
def destroy
|
|
57
|
+
@book.destroy
|
|
58
|
+
respond_to do |format|
|
|
59
|
+
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
|
|
60
|
+
format.json { head :no_content }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
66
|
+
def set_book
|
|
67
|
+
@book = Book.find(params[:id])
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
|
71
|
+
def book_params
|
|
72
|
+
params.fetch(:book, {})
|
|
73
|
+
end
|
|
74
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class SessionsController < ApplicationController
|
|
2
|
+
def create
|
|
3
|
+
user = User.from_omniauth env['omniauth.auth']
|
|
4
|
+
session[:user_id] = user.id
|
|
5
|
+
redirect_to root_url, notice: 'Signed in successfully'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def failure
|
|
9
|
+
redirect_to root_url, notice: 'Sign in failed'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def destroy
|
|
13
|
+
session.delete(:user_id)
|
|
14
|
+
redirect_to root_url, notice: 'Signed out successfully'
|
|
15
|
+
end
|
|
16
|
+
end
|