Merge branch 'omniauth'

This commit is contained in:
Christoph Haas 2017-04-17 00:02:41 +02:00
commit 4d41ea6bce
35 changed files with 391 additions and 165 deletions

14
Gemfile
View file

@ -111,16 +111,14 @@ gem "font-awesome-rails"
# gem "recaptcha", require: "recaptcha/rails"
gem "sprockets", '3.6.3'
gem "sprockets"
#gem "activemodel-serializers-xml"
# Authentication against Google, Facebook and others
gem 'omniauth'
gem 'omniauth-amazon'
gem 'omniauth-google-oauth2'
gem 'omniauth-github'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
# gem 'omniauth-launchpad' # is broken
gem 'omniauth-launchpad', :git => 'https://github.com/joaopapereira/omniauth-launchpad'
# gem 'omniauth-amazon'
# gem 'omniauth-google-oauth2'
# gem 'omniauth-github'
# gem 'omniauth-twitter'
gem 'omniauth-openid'

View file

@ -4,15 +4,6 @@ GIT
specs:
bzip2-ruby (0.2.7)
GIT
remote: https://github.com/joaopapereira/omniauth-launchpad
revision: 948a3c405594651b775457db87f62b7d61e1824d
specs:
omniauth-launchpad (0.0.1)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth
GEM
remote: https://rubygems.org/
specs:
@ -95,8 +86,6 @@ GEM
execjs (2.7.0)
fancybox2-rails (0.2.7)
railties (>= 3.1.0)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
@ -135,7 +124,6 @@ GEM
js_cookie_rails (2.1.4)
railties (>= 3.1)
json (1.8.6)
jwt (1.5.6)
libv8 (3.16.14.19)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
@ -161,8 +149,6 @@ GEM
minitest (>= 5.0)
ruby-progressbar
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nenv (0.3.0)
nio4r (2.0.0)
nokogiri (1.7.1)
@ -170,38 +156,12 @@ GEM
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
oauth (0.5.1)
oauth2 (1.3.1)
faraday (>= 0.8, < 0.12)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-amazon (1.0.1)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-github (1.2.3)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0, < 2.0)
omniauth-google-oauth2 (0.4.1)
jwt (~> 1.5.2)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.3.1)
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
rack-openid (~> 1.3.1)
orm_adapter (0.5.0)
paperclip (5.1.0)
activemodel (>= 4.2.0)
@ -220,6 +180,9 @@ GEM
slop (~> 3.4)
puma (3.8.2)
rack (2.0.1)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.2)
@ -259,6 +222,7 @@ GEM
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
ruby-graphviz (1.2.3)
ruby-openid (2.7.0)
ruby-progressbar (1.8.1)
sass (3.4.23)
sass-rails (5.0.6)
@ -284,7 +248,7 @@ GEM
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.6.3)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-es6 (0.9.2)
@ -307,7 +271,7 @@ GEM
turbolinks-source (5.0.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.1.13)
uglifier (3.2.0)
execjs (>= 0.3.0, < 3)
warden (1.2.7)
rack (>= 1.0)
@ -343,12 +307,7 @@ DEPENDENCIES
minitest-rails
minitest-reporters
omniauth
omniauth-amazon
omniauth-facebook
omniauth-github
omniauth-google-oauth2
omniauth-launchpad!
omniauth-twitter
omniauth-openid
paperclip
pg
pg_search
@ -360,7 +319,7 @@ DEPENDENCIES
slim-rails
spring
spring-watcher-listen (~> 2.0.0)
sprockets (= 3.6.3)
sprockets
therubyracer
turbolinks (~> 5)
uglifier (>= 1.3.0)

View file

@ -1,57 +1,30 @@
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# def passthru
# raise
# send(params[:provider]) if providers.include?(params[:provider])
# end
# Workaround for https://github.com/plataformatec/devise/issues/2432
skip_before_filter :verify_authenticity_token
def launchpad
login_via 'Launchpad'
end
def stackexchange
login_via 'StackExchange'
end
def login_via(provider_name)
# 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?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Launchpad"
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => provider_name
sign_in_and_redirect @user, :event => :authentication
else
# session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) #Removing extra as it can overflow some session stores
redirect_to new_user_session_url, alert: @user.errors.full_messages.join("\n")
end
end
def google_oauth2
# 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?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
sign_in_and_redirect @user, :event => :authentication
else
# session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) #Removing extra as it can overflow some session stores
redirect_to new_user_session_url, alert: @user.errors.full_messages.join("\n")
end
end
def amazon
# 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?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Amazon"
sign_in_and_redirect @user, :event => :authentication
else
# session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) #Removing extra as it can overflow some session stores
redirect_to new_user_session_url, alert: @user.errors.full_messages.join("\n")
end
def failure
redirect_to root_path
end
# def failure
# redirect_to root_path
# end
# private
#
# def providers
# ["twitter", "google_oauth2", "launchpad", "amazon"]
# end
end

View file

@ -1,23 +1,25 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
# :registerable,
:recoverable,
# :recoverable,
# :rememberable,
:trackable,
# :validatable,
:timeoutable,
# :lockable,
:omniauthable, :omniauth_providers => [:google_oauth2, :launchpad, :amazon]
# :omniauthable, :omniauth_providers => [:launchpad, :google]
:omniauthable, :omniauth_providers => [:launchpad,:stackexchange]
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
where(provider: auth.provider, email: auth.info.email).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
user.name = auth.info.name
# Set a random password
user.password = Devise.friendly_token[0,20]
end
end

View file

@ -0,0 +1,5 @@
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>

View file

@ -0,0 +1,3 @@
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>

View file

@ -0,0 +1,8 @@
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>

View file

@ -0,0 +1,7 @@
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>

View file

@ -0,0 +1,25 @@
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -0,0 +1,16 @@
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -0,0 +1,43 @@
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<% end %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Update" %>
</div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>

View file

@ -0,0 +1,29 @@
<h2>Sign up</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -35,8 +35,21 @@
/ = link_to 'log in using your secure certificate', users_debian_sso_path
/ = link_to "Sign in with Launchpad", user_launchpad_omniauth_authorize_path
= link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path
/ = link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path
= link_to "Sign in with Launchpad", user_launchpad_omniauth_authorize_path
= link_to "Sign in with StackExchange", user_stackexchange_omniauth_authorize_path
= link_to "Sign in with Amazon", user_amazon_omniauth_authorize_path
/ div
/ = link_to image_tag('/images/sso/google.png'), user_google_oauth2_omniauth_authorize_path
/ div
/ = link_to "google new", user_google_omniauth_authorize_path
/
/ div
/ = link_to image_tag('/images/sso/amazon.png'), user_amazon_omniauth_authorize_path
/
/ div
/ stackexchange
/

View file

@ -0,0 +1,25 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>

View file

@ -0,0 +1,16 @@
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>

View file

@ -1,23 +0,0 @@
// Show users' own uploaded screenshots in this session
/ = link_to 'Back', :back, class: 'button small'
.row.packagepage
h1 Screenshots you uploaded
- @packages.each do |package|
h2 Package #{package.name}
.subtitle
= package.description
.small-9.large-10.columns
- if @current_users_screenshots.length>0
.row.small-up-1.medium-up-3.large-up-4.grid-thumbnails
- @current_users_screenshots.each do |screenshot|
.column
a.black.fancybox href=screenshot.image.url(:large, timestamp: false)
div.grid-thumbnail
= image_tag(screenshot.image.url(:thumb, timestamp: false), alt: screenshot.caption, class: 'thumbnail')
div
= screenshot.description

View file

@ -1,9 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

View file

@ -1,9 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run

34
bin/setup Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

29
bin/update Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

View file

@ -50,7 +50,7 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Suppress logger output for asset requests.
config.assets.quiet = true

View file

@ -16,7 +16,8 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
@ -87,12 +88,6 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_files = false
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.package_sources = [
{
description: 'Debian Unstable (Sid)', type: 'apt', url: 'http://ftp.de.debian.org/debian/dists/sid',

View file

@ -12,15 +12,12 @@ Debshots::Application.configure do
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# ActiveRecord errors propagate normally (forward deprecation to Rails 5)
config.active_record.raise_in_transactional_callbacks = true
# Test :sorted or :random. ":random" may be safer but harder to debug.
config.active_support.test_order = :sorted
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
config.public_file_server.enabled = true
config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
# Show full error reports and disable caching.
config.consider_all_requests_local = true
@ -57,5 +54,5 @@ Debshots::Application.configure do
config.image_sizes = {
large: '800x600',
small: '160x120',
}
}
end

View file

@ -0,0 +1,6 @@
# Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )

View file

@ -0,0 +1,11 @@
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )

View file

@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :marshal

View file

@ -243,7 +243,7 @@ Devise.setup do |config|
# config.navigational_formats = ['*/*', :html]
# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :delete
# config.sign_out_via = :delete
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
@ -274,12 +274,15 @@ Devise.setup do |config|
# config.omniauth_path_prefix = '/my_engine/users/auth'
# config.omniauth :launchpad, 'debshots'
config.omniauth :google_oauth2, '398593918966-0fpmit0pb6ptio1ndsie5dfcnqhei63l.apps.googleusercontent.com', 'uRQq_dLs1kx7l5sYIyEyPVRc', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
# config.omniauth :google_oauth2, '398593918966-0fpmit0pb6ptio1ndsie5dfcnqhei63l.apps.googleusercontent.com', 'uRQq_dLs1kx7l5sYIyEyPVRc', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
#
# # config.omniauth :launchpad, 'Debian Screenshots', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
#
# config.omniauth :amazon, 'amzn1.application-oa2-client.78d832919fc24456b0636762cf18efd9', '8c495d0940ca4100313c03e93b8b4240eef256d2fdbe672718506f29f5a20f61', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
config.omniauth :launchpad, 'Debian Screenshots', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
config.omniauth :open_id, name: :stackexchange, identifier: 'https://openid.stackexchange.com', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
config.omniauth :open_id, name: :launchpad, identifier: 'https://login.ubuntu.com', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
config.omniauth :amazon, 'amzn1.application-oa2-client.78d832919fc24456b0636762cf18efd9', '8c495d0940ca4100313c03e93b8b4240eef256d2fdbe672718506f29f5a20f61', :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
# client_options: {ssl: {ca_path: '/etc/ssl/certs'}}
end
# OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

View file

@ -2,4 +2,3 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

View file

@ -0,0 +1,23 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = false
# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = false
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true

View file

@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.
Debshots::Application.config.session_store :cookie_store, key: '_debshots_session'
Rails.application.config.session_store :cookie_store, key: '_debshots_session'

View file

@ -5,10 +5,10 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# self.include_root_in_json = true
# end

View file

@ -23,6 +23,8 @@ en:
subject: "Reset password instructions"
unlock_instructions:
subject: "Unlock instructions"
email_changed:
subject: "Email Changed"
password_change:
subject: "Password Changed"
omniauth_callbacks:

View file

@ -7,8 +7,8 @@ Debshots::Application.routes.draw do
get 'admin/integration'
devise_for :users, controllers: {
registrations: "users/registrations",
passwords: "users/passwords",
# registrations: "users/registrations",
# passwords: "users/passwords",
omniauth_callbacks: "users/omniauth_callbacks"
}

View file

@ -0,0 +1,19 @@
require "test_helper"
describe AdminController do
it "should get status" do
get admin_status_url
value(response).must_be :success?
end
it "should get screenshots" do
get admin_screenshots_url
value(response).must_be :success?
end
it "should get integration" do
get admin_integration_url
value(response).must_be :success?
end
end

View file

@ -0,0 +1,14 @@
require "test_helper"
describe MyController do
it "should get index" do
get my_index_url
value(response).must_be :success?
end
it "should get uploads" do
get my_uploads_url
value(response).must_be :success?
end
end