Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
a7a9db1
Adds documentcloud accounts integration (omniauth), cleans up previou…
esthervillars Oct 27, 2016
9881a39
Fixes for seeds, makes single membership the default for seeded users
esthervillars Nov 29, 2016
2c26feb
Fixes initializer, updates routes based on dc platform vs implementer…
esthervillars Nov 30, 2016
80db547
Adds documentcloud accounts integration (omniauth), cleans up previou…
esthervillars Oct 27, 2016
ad24dfb
Fixes for seeds, makes single membership the default for seeded users
esthervillars Nov 29, 2016
02b6b91
Fixes initializer, updates routes based on dc platform vs implementer…
esthervillars Nov 30, 2016
cbf261f
Updates
esthervillars Dec 12, 2016
87cd1ff
Don’t use `dc-design-transition` class
reefdog Dec 28, 2016
bab4430
Update gems
reefdog Dec 28, 2016
2e0fad9
Consolidate workspace JS in workspace template
reefdog Dec 29, 2016
f351aec
Add settings for account URLs
reefdog Jan 3, 2017
f1c5997
Remove unnecessary `@additional_js` in workspace
reefdog Jan 4, 2017
c436abd
Merge branch 'master' into dc_omniauth
reefdog Jan 4, 2017
b9d7a48
Update common meta tags
reefdog Jan 4, 2017
6eee5a4
Remove unused constant
reefdog Jan 4, 2017
76d1f6b
Don’t redirect to browser upgrade page
reefdog Jan 4, 2017
764fdcd
Cleanup workspace controller a bit
reefdog Jan 4, 2017
5902bb4
Improve and consolidate nav
reefdog Jan 4, 2017
6107718
Attach News XYZ admin seed to correct org
reefdog Jan 5, 2017
d8df2b2
Make siteadmin seed a member of News XYZ too
reefdog Jan 5, 2017
c9a4bf7
Add new headers to workspace
reefdog Jan 5, 2017
bfb3d24
Add upgrade banner to workspace for IE10- #437
reefdog Jan 5, 2017
7a2e074
Disarm some public controller hashrockets
reefdog Jan 5, 2017
08f8401
Merge branch 'dc_omniauth' of https://github.com/documentcloud/docume…
esthervillars Jan 5, 2017
d86a7d3
Use `current_organization` accessor in AccountsController
reefdog Jan 6, 2017
6ba2c3e
Sync workspace and accounts controller return style
reefdog Jan 6, 2017
9c25461
Align an assigment
reefdog Jan 6, 2017
c5dca22
Clean up syntax of the organization model
reefdog Jan 6, 2017
cf66439
Disarm some hashrockets
reefdog Jan 9, 2017
58c9ea5
Remove unnecessary partial type option
reefdog Jan 9, 2017
9fb67aa
Add note about syncing account/workspace index
reefdog Jan 9, 2017
fd1bbb9
Remove unused account search stubs
reefdog Jan 9, 2017
5380a7c
Clean up Membership model syntax
reefdog Jan 9, 2017
49c72c2
Add membership concept to front end [WIP]
reefdog Jan 10, 2017
20caa83
Correct `include_organization` option name
reefdog Jan 10, 2017
9247a06
Include memberships when return account JSON
reefdog Jan 10, 2017
86938bf
Observe jQuery events with `on`, not `bind`
reefdog Jan 10, 2017
9cdf11f
wip
esthervillars Jan 10, 2017
986adea
Remove more old omniauth/iframe login stuff
reefdog Jan 10, 2017
309ec0d
Remove old `home/help` routes
reefdog Jan 10, 2017
a992420
Remove workspace tabs and don’t init account mgr
reefdog Jan 10, 2017
8d38948
Redirect /accounts to Circlet
reefdog Jan 10, 2017
7fa83f5
Add stub org switcher
reefdog Jan 10, 2017
2f57ad5
Improve construction of org switcher menu
reefdog Jan 12, 2017
01deae8
Generate button gradients with CSS
reefdog Jan 12, 2017
d36e986
Move upload/create buttons to org bar [WIP]
reefdog Jan 13, 2017
81658a4
Add Account#role TODO
reefdog Jan 17, 2017
0ddb885
Let `Account.member_of?` accept an ID
reefdog Jan 17, 2017
bfe7870
Update Account#role TODO and default membership
reefdog Jan 17, 2017
5b353ea
Start tracking membership ID upon login [WIP]
reefdog Jan 17, 2017
40dbad5
Stub sessions actions for switching memberships
reefdog Jan 17, 2017
85ddf36
Switch both membership and organization IDs
reefdog Jan 17, 2017
80610ee
Init org switcher in correct place
reefdog Jan 18, 2017
2b596fe
Add `app:devstop` rake task
reefdog Jan 18, 2017
eb8d408
platform integration chagnes for demo
esthervillars Jan 19, 2017
86e0c8e
wip
esthervillars Jan 19, 2017
a58dd7b
prevs project-orgs changes, and recent for organizations like mini orgs
esthervillars Jan 19, 2017
ab6e7ad
fixes merge conflict on accounts
esthervillars Jan 19, 2017
16dc5d5
fixes more merge conflicts
esthervillars Jan 19, 2017
992b4c9
fix test exports for memberships and orgs
esthervillars Jan 20, 2017
0cedbca
use the default membership organization if one is not set
esthervillars Jan 20, 2017
2a8ef2d
Fix templates for Bootstrap v4alpha6
reefdog Jan 23, 2017
5d29562
Add `navbar-light` class to navbar
reefdog Jan 23, 2017
b8cc049
Decrease min-height of dc.ui.Panel
reefdog Jan 23, 2017
182096e
Switch memberships using full request cycle
reefdog Jan 24, 2017
506d03f
Seeds in staging pix
knowtheory Jan 24, 2017
929f65e
Move location of “you are [role]” message
reefdog Jan 24, 2017
88ff19a
Mark current membership as active in menu
reefdog Jan 24, 2017
361eaa8
Stub loading only current_membership’s Projects
reefdog Jan 24, 2017
17b1f29
Adds invite and accept to Collaboration
esthervillars Jan 24, 2017
68261cc
Remove project when accepting collaboration invitation
esthervillars Jan 24, 2017
b47c6b9
Adds collaboration accept route
esthervillars Jan 24, 2017
18d347f
Accepts collaboration for project creator on controller action:
esthervillars Jan 24, 2017
548c9f6
Align some assignments
reefdog Jan 24, 2017
920b795
Remove more frontend membership switching
reefdog Jan 24, 2017
27b9c1b
Use `account.currentOrganization()` for clarity
reefdog Jan 24, 2017
e9d4533
Add some WIP comments for myself to the JS
reefdog Jan 24, 2017
2da7826
Update schema
reefdog Jan 24, 2017
acdf54b
Hide projects from other organizations.
knowtheory Jan 24, 2017
6fdbe77
Remove TODO
reefdog Jan 24, 2017
1f472ec
Remove GA+editing partials from doc preview layout
reefdog Jan 24, 2017
f385dd7
Only show current organization search links
reefdog Jan 24, 2017
b6b89fd
Remove unused stub divider from navbar
reefdog Jan 24, 2017
3239d31
Show org name instead of doc count in upload dialog
reefdog Jan 26, 2017
401e3e3
Merge branch 'master' into dc_omniauth
knowtheory Jan 30, 2017
02c23d5
Update templates for Bootstrap v4alpha6
reefdog Jan 30, 2017
59c2492
Backmerge master and resolve merge conflicts
esthervillars Jan 30, 2017
16e83e4
Remove unused CSS
reefdog Feb 11, 2017
b8a2017
Consolidate `/search` route naming as `workspace`
reefdog Feb 13, 2017
ef6974f
Delete unused nav partials
reefdog Feb 13, 2017
16e1b35
Add titles to sidebar sections
reefdog Feb 14, 2017
90e42bf
Mockup of project invitations in sidebar
reefdog Feb 14, 2017
ab05575
Stub `ProjectInvitation` model/collection
reefdog Feb 14, 2017
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ cloud_crowd.db
.DS_Store
public/search
vendor/solr-4.0.0/solr-webapp/webapp/*
vendor/cache/*
.bundle
public/javascripts/vendor/*/
.vagrant
.tm_properties
Vagrantfile
*.sublime-*
.byebug_history
doc

18 changes: 14 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ gem 'sunspot_rails', '2.2.0'
gem 'sunspot_solr', '2.2.0'
gem 'progress_bar' # Optional, used by sunspot to show progress while re-indexing

gem 'omniauth', '~> 1.2.1'
gem 'omniauth-twitter', '~> 1.0'
gem 'omniauth-facebook', '~> 1.6'
gem 'omniauth-google-oauth2', '~> 0.2'
# TODO: omniauth cleanup remove me
# gem 'omniauth',
# gem 'omniauth-twitter', '~> 1.0'
# gem 'omniauth-facebook', '~> 1.6'
# gem 'omniauth-google-oauth2', '~> 0.2'

# Auth
gem 'omniauth', '~> 1.3.1'
gem 'omniauth-oauth2'

gem 'sanitize', '~> 2.0.6'
gem 'rdiscount', '~> 2.1.6'
gem 'rake'
Expand Down Expand Up @@ -58,6 +64,7 @@ group :development, :test do
gem 'byebug' # Debugger
gem 'factory_girl_rails' # Mocking out objects
gem 'ruby-debug-passenger'

end

group :development do
Expand All @@ -66,6 +73,9 @@ group :development do
# by a developer on their local machine before committing the compiled strings
gem 'google_drive', '~> 1.0.0'
gem 'highline'
gem 'better_errors'
gem 'binding_of_caller'
# gem 'railroady'
end

group :test do
Expand Down
64 changes: 29 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.3)
arel (6.0.4)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
Expand All @@ -94,6 +94,12 @@ GEM
json (~> 1.4)
nokogiri (>= 1.4.4)
bcrypt (3.1.11)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.6)
closure-compiler (1.1.12)
Expand All @@ -106,7 +112,7 @@ GEM
sinatra
thin (>= 1.2.4)
coderay (1.1.1)
concurrent-ruby (1.0.2)
concurrent-ruby (1.0.4)
countries (0.11.5)
currencies (~> 0.4.2)
i18n_data (~> 0.7.0)
Expand All @@ -119,19 +125,20 @@ GEM
curb (0.8.8)
currencies (0.4.2)
daemons (1.2.4)
debug_inspector (0.0.2)
docsplit (0.8.0.alpha1)
domain_name (0.5.20161129)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
eventmachine (1.2.1)
excon (0.54.0)
extlib (0.9.16)
factory_girl (4.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.7.0)
factory_girl (~> 4.7.0)
factory_girl_rails (4.8.0)
factory_girl (~> 4.8.0)
railties (>= 3.0.0)
faraday (0.9.2)
faraday (0.10.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.1)
faraday (>= 0.7.4, < 1.0)
Expand Down Expand Up @@ -183,7 +190,7 @@ GEM
minitest (>= 3.0)
has_secure_token (1.0.0)
activerecord (>= 3.0)
hashdiff (0.3.1)
hashdiff (0.3.2)
hashie (3.4.6)
highline (1.7.8)
http-cookie (1.0.3)
Expand Down Expand Up @@ -231,34 +238,21 @@ GEM
nenv (~> 0.1)
shellany (~> 0.0)
oauth (0.5.1)
oauth2 (1.2.0)
faraday (>= 0.8, < 0.10)
oauth2 (1.3.0)
faraday (>= 0.8, < 0.11)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.2.2)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1)
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)
rack (>= 1.0, < 3)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-twitter (1.2.1)
json (~> 1.3)
omniauth-oauth (~> 1.1)
options (2.3.2)
os (0.9.6)
passenger (5.0.30)
passenger (5.1.1)
rack
rake (>= 0.8.1)
pdfshaver (0.0.3)
Expand All @@ -275,7 +269,7 @@ GEM
pry-remote (0.1.8)
pry (~> 0.9)
slop (~> 3.0)
public_suffix (2.0.4)
public_suffix (2.0.5)
rack (1.6.5)
rack-protection (1.5.3)
rack
Expand All @@ -294,9 +288,9 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
Expand Down Expand Up @@ -338,7 +332,7 @@ GEM
unicode_utils (>= 1.2.2)
spring (2.0.0)
activesupport (>= 4.2)
sprockets (3.7.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.0)
Expand Down Expand Up @@ -372,7 +366,7 @@ GEM
unf_ext (0.0.7.2)
unicode_utils (1.4.0)
vcr (3.0.3)
webmock (2.3.1)
webmock (2.3.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand All @@ -385,6 +379,8 @@ DEPENDENCIES
active_model_serializers (~> 0.9.0)
aws-sdk (~> 1.30)
bcrypt (~> 3.1.1)
better_errors
binding_of_caller
bootstrap_form!
bull_proof_china_shop!
byebug
Expand All @@ -405,10 +401,8 @@ DEPENDENCIES
minitest-spec-rails
net-ssh-shell
nokogiri (~> 1.6.0)
omniauth (~> 1.2.1)
omniauth-facebook (~> 1.6)
omniauth-google-oauth2 (~> 0.2)
omniauth-twitter (~> 1.0)
omniauth (~> 1.3.1)
omniauth-oauth2
open_calais!
passenger
pdfshaver (>= 0.0.2)
Expand All @@ -433,4 +427,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.12.5
1.13.7
22 changes: 6 additions & 16 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ class AccountsController < ApplicationController
before_action :login_required, except: [:enable, :reset, :logged_in]
before_action :bouncer, only: [:enable, :reset] if exclusive_access?

READONLY_ACTIONS = [
:index, :logged_in, :resend_welcome
]
READONLY_ACTIONS = [:index, :logged_in, :resend_welcome].freeze

before_action :read_only_error, except: READONLY_ACTIONS if read_only?

# Enabling an account continues the second half of the signup process,
Expand Down Expand Up @@ -44,19 +43,10 @@ def reset
end
end

# Requesting /accounts returns the list of accounts in your logged-in organization.
# consider extracting the HTML info into a single method in common w/ workspace
def index
respond_to do |format|
format.html do
if logged_in? and current_account.real?
@projects = Project.load_for(current_account)
@current_organization = current_account.organization
@organizations = Organization.all_slugs
@has_documents = Document.owned_by(current_account).exists?
return render template: 'workspace/index', layout: 'workspace'
end
redirect_to public_search_url(query: params[:query])
redirect_to File.join(DC::SECRETS['omniauth']['documentcloud']['site'], '/organizations/')
end
format.json do
json current_organization.accounts.active
Expand Down Expand Up @@ -140,15 +130,15 @@ def resend_welcome
LifecycleMailer.login_instructions(account, current_organization, current_account).deliver_now
json nil
end

def mailboxes
# TODO: Filter by status, once that exists
@mailboxes = UploadMailbox.where(membership_id: current_account.memberships.pluck(:id))
set_minimal_nav text: 'Back to the workspace',
xs_text: 'Workspace',
link: '/search/'
end

def create_mailbox
@mailbox = UploadMailbox.create(membership: current_account.memberships.default.first, sender: params[:email])
if @mailbox.valid?
Expand All @@ -158,7 +148,7 @@ def create_mailbox
end
redirect_to :mailboxes
end

def revoke_mailbox
@mailbox = UploadMailbox.find(params[:id])
return forbidden unless @mailbox.membership.account == current_account
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def all_accounts
'public_per_account' => DC::Statistics.public_documents_per_account,
'private_per_account' => DC::Statistics.private_documents_per_account,
'pages_per_account' => DC::Statistics.pages_per_account,
'accounts' => Account.all.map {|a| a.canonical(:include_organization => true) }
'accounts' => Account.all.map {|a| a.canonical(include_organizations: true) }
})
end

Expand Down
67 changes: 64 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def embeddable?
def cachable?
request.get? and not logged_in?
end

def make_oembeddable(resource)
# Resource should have both an `oembed_url` and a `title`
@oembeddable_resource = resource
Expand Down Expand Up @@ -170,6 +170,7 @@ def validate_session

def logged_in?
!!current_account
# return true if current_account
end

def clear_login_state
Expand Down Expand Up @@ -233,6 +234,12 @@ def current_organization
session['organization_id'] ? Organization.find_by_id(session['organization_id']) : nil
end

def current_membership
return nil unless request.ssl?
@current_membership ||=
session['membership_id'] ? Membership.find(session['membership_id']) : nil
end

def handle_unverified_request
error = RuntimeError.new "CSRF Verification Failed"
LifecycleMailer.exception_notification(error, params).deliver_now
Expand Down Expand Up @@ -346,8 +353,63 @@ def set_minimal_nav(text: 'Go to home', xs_text: false, link: '/')
@minimal_back_link = link
end

# helper_method :current_account
# helper_method :account_signed_in?
helper_method :correct_account?

## Feature Flags
# Dynamically get a list of all implemented feature flags
feature_flags = FeatureFlags.public_instance_methods
# Delegate all feature flag methods to current_account
delegate *feature_flags, to: :current_account, allow_nil: true
# Make feature flag methods available in views
helper_method feature_flags

## OAuth2 Client
def documentcloud_oauth_client
unless DC::Application.config.you_are_documentcloud
@client ||= OAuth2::Client.new(DC::SECRETS['omniauth']['documentcloud']['key'],
DC::SECRETS['omniauth']['documentcloud']['secret'],
site: DC::SECRETS['omniauth']['documentcloud']['site'],
callback_url: DC::SECRETS['omniauth']['documentcloud']['callback_url'],
client_options: { ssl: { verify: !Rails.env.development? } })
end
end

def documentcloud_access_token
unless DC::Application.config.you_are_documentcloud
@token ||= OAuth2::AccessToken.new(documentcloud_oauth_client,
current_account.access_token) if current_account
end
end

private


# def current_account use current_account
# begin
# @current_account ||= Account.find(session[:account_id]) if session[:account_id]
# rescue Exception => e
# nil
# end
# end

# def account_signed_in? use logged_in?
# return true if current_account
# end

def correct_account?
@account = Account.find(params[:id])
unless current_account == @account
redirect_to root_url, alert: 'Access denied'
end
end

def authenticate_user!
unless current_account
redirect_to root_url, alert: 'Please log in or sign up for access to this page.'
end
end

# Generic error response helper. Defaults to 200 because never called directly
def error_response(status=200, options={})
options = {
Expand All @@ -366,5 +428,4 @@ def error_response(status=200, options={})

false
end

end
Loading