mtwarden 6.0.1 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -20
- data/README.md +35 -35
- data/Rakefile +33 -33
- data/app/assets/config/mtwarden_manifest.js +2 -2
- data/app/assets/javascripts/mtwarden/application.js +2 -2
- data/app/assets/stylesheets/mtwarden/application.scss +2 -2
- data/app/controllers/mtwarden/account/accounts_controller.rb +67 -67
- data/app/controllers/mtwarden/account/dashboard_controller.rb +7 -7
- data/app/controllers/mtwarden/account/sessions_controller.rb +20 -20
- data/app/controllers/mtwarden/account/users_controller.rb +23 -23
- data/app/controllers/mtwarden/accounts_controller.rb +32 -32
- data/app/controllers/mtwarden/application_controller.rb +12 -12
- data/app/controllers/mtwarden/dashboard_controller.rb +6 -6
- data/app/extenders/controllers/application_controller_extender.rb +38 -38
- data/app/helpers/mtwarden/application_helper.rb +4 -4
- data/app/jobs/mtwarden/application_job.rb +4 -4
- data/app/mailers/mtwarden/application_mailer.rb +8 -8
- data/app/models/mtwarden/account.rb +39 -39
- data/app/models/mtwarden/application_record.rb +5 -5
- data/app/models/mtwarden/member.rb +6 -6
- data/app/models/mtwarden/plan.rb +4 -4
- data/app/models/mtwarden/user.rb +7 -7
- data/app/views/layouts/mtwarden/application.html.erb +16 -16
- data/app/views/mtwarden/account/accounts/_existing_subscription.html.erb +3 -3
- data/app/views/mtwarden/account/accounts/_new_subscription.html.erb +38 -38
- data/app/views/mtwarden/account/accounts/edit.html.erb +17 -17
- data/app/views/mtwarden/account/accounts/plan.html.erb +14 -14
- data/app/views/mtwarden/account/dashboard/index.html.erb +1 -1
- data/app/views/mtwarden/account/sessions/new.html.erb +19 -19
- data/app/views/mtwarden/account/users/_form.html.erb +14 -14
- data/app/views/mtwarden/account/users/new.html.erb +6 -6
- data/app/views/mtwarden/accounts/new.html.erb +20 -20
- data/app/views/mtwarden/dashboard/index.html.erb +1 -1
- data/app/views/mtwarden/shared/_login.html.erb +7 -7
- data/config/initializers/warden/strategies/password.rb +18 -18
- data/config/routes.rb +30 -30
- data/db/migrate/20140621030847_create_mtwarden_accounts.rb +11 -11
- data/db/migrate/20140621114149_add_owner_id_to_mtwarden_accounts.rb +7 -7
- data/db/migrate/20140621114231_create_mtwarden_users.rb +12 -12
- data/db/migrate/20140621114308_create_mtwarden_members.rb +12 -12
- data/db/migrate/20140621114417_add_subdomain_to_mtwarden_accounts.rb +8 -8
- data/db/migrate/20140829231923_create_mtwarden_plans.rb +13 -13
- data/db/migrate/20140830011033_add_plan_id_to_mtwarden_accounts.rb +7 -7
- data/db/migrate/20140830020346_add_braintree_subscription_id_to_mtwarden_accounts.rb +7 -7
- data/lib/mtwarden.rb +4 -4
- data/lib/mtwarden/braintree_plan_fetcher.rb +22 -22
- data/lib/mtwarden/constraints/subdomain_required.rb +11 -11
- data/lib/mtwarden/engine.rb +52 -52
- data/lib/mtwarden/scoped_to.rb +9 -9
- data/lib/mtwarden/testing_support/authentication_helpers.rb +21 -21
- data/lib/mtwarden/testing_support/factories/account_factory.rb +14 -14
- data/lib/mtwarden/testing_support/factories/user_factory.rb +7 -7
- data/lib/mtwarden/testing_support/subdomain_helpers.rb +16 -16
- data/lib/mtwarden/version.rb +3 -3
- data/lib/tasks/mtwarden_tasks.rake +6 -6
- metadata +23 -53
@@ -1,17 +1,17 @@
|
|
1
|
-
<h2>Edit Account</h2>
|
2
|
-
|
3
|
-
<%= form_for(current_account, :url => account_path) do |account| %>
|
4
|
-
<%= account.error_messages %>
|
5
|
-
<p>
|
6
|
-
<%= account.label :name %>
|
7
|
-
<%= account.text_field :name %>
|
8
|
-
</p>
|
9
|
-
|
10
|
-
<p>
|
11
|
-
<%= account.label :plan_id %>
|
12
|
-
<% plans = Mtwarden::Plan.all.map { |p| [p.name, p.id] } %>
|
13
|
-
<%= account.select :plan_id, plans %>
|
14
|
-
</p>
|
15
|
-
|
16
|
-
<%= account.submit "Update Account" %>
|
17
|
-
<% end %>
|
1
|
+
<h2>Edit Account</h2>
|
2
|
+
|
3
|
+
<%= form_for(current_account, :url => account_path) do |account| %>
|
4
|
+
<%= account.error_messages %>
|
5
|
+
<p>
|
6
|
+
<%= account.label :name %>
|
7
|
+
<%= account.text_field :name %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%= account.label :plan_id %>
|
12
|
+
<% plans = Mtwarden::Plan.all.map { |p| [p.name, p.id] } %>
|
13
|
+
<%= account.select :plan_id, plans %>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
<%= account.submit "Update Account" %>
|
17
|
+
<% end %>
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<div class='plan-info'>
|
2
|
-
<p>
|
3
|
-
You are changing to the '<%= @plan.name %>' plan.
|
4
|
-
</p>
|
5
|
-
<p>
|
6
|
-
This plan costs <strong>$<%= @plan.price %></strong> per month.
|
7
|
-
</p>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<% if current_account.braintree_subscription_id.present? %>
|
11
|
-
<%= render "existing_subscription" %>
|
12
|
-
<% else %>
|
13
|
-
<%= render "new_subscription" %>
|
14
|
-
<% end %>
|
1
|
+
<div class='plan-info'>
|
2
|
+
<p>
|
3
|
+
You are changing to the '<%= @plan.name %>' plan.
|
4
|
+
</p>
|
5
|
+
<p>
|
6
|
+
This plan costs <strong>$<%= @plan.price %></strong> per month.
|
7
|
+
</p>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<% if current_account.braintree_subscription_id.present? %>
|
11
|
+
<%= render "existing_subscription" %>
|
12
|
+
<% else %>
|
13
|
+
<%= render "new_subscription" %>
|
14
|
+
<% end %>
|
@@ -1 +1 @@
|
|
1
|
-
Your account's dashboard. Coming soon.
|
1
|
+
Your account's dashboard. Coming soon.
|
@@ -1,19 +1,19 @@
|
|
1
|
-
<h2>Sign in</h2>
|
2
|
-
|
3
|
-
<%= form_for @user, :url => sessions_url do |f| %>
|
4
|
-
<p>
|
5
|
-
<%= f.label :email %><br>
|
6
|
-
<%= f.email_field :email %>
|
7
|
-
</p>
|
8
|
-
|
9
|
-
<p>
|
10
|
-
<%= f.label :password %><br>
|
11
|
-
<%= f.password_field :password %>
|
12
|
-
</p>
|
13
|
-
|
14
|
-
<p>
|
15
|
-
<%= f.submit "Sign in" %>
|
16
|
-
</p>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<%= link_to "New User?", user_sign_up_url %>
|
1
|
+
<h2>Sign in</h2>
|
2
|
+
|
3
|
+
<%= form_for @user, :url => sessions_url do |f| %>
|
4
|
+
<p>
|
5
|
+
<%= f.label :email %><br>
|
6
|
+
<%= f.email_field :email %>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
<%= f.label :password %><br>
|
11
|
+
<%= f.password_field :password %>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
<%= f.submit "Sign in" %>
|
16
|
+
</p>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= link_to "New User?", user_sign_up_url %>
|
@@ -1,14 +1,14 @@
|
|
1
|
-
<p>
|
2
|
-
<%= user.label :email %><br>
|
3
|
-
<%= user.email_field :email %>
|
4
|
-
</p>
|
5
|
-
|
6
|
-
<p>
|
7
|
-
<%= user.label :password %><br>
|
8
|
-
<%= user.password_field :password %>
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<p>
|
12
|
-
<%= user.label :password_confirmation %><br>
|
13
|
-
<%= user.password_field :password_confirmation %>
|
14
|
-
</p>
|
1
|
+
<p>
|
2
|
+
<%= user.label :email %><br>
|
3
|
+
<%= user.email_field :email %>
|
4
|
+
</p>
|
5
|
+
|
6
|
+
<p>
|
7
|
+
<%= user.label :password %><br>
|
8
|
+
<%= user.password_field :password %>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<%= user.label :password_confirmation %><br>
|
13
|
+
<%= user.password_field :password_confirmation %>
|
14
|
+
</p>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h2>Sign Up</h2>
|
2
|
-
|
3
|
-
<%= form_for(@user, :url => do_user_sign_up_url) do |user| %>
|
4
|
-
<%= render "mtwarden/account/users/form", :user => user %>
|
5
|
-
<%= user.submit "Sign up" %>
|
6
|
-
<% end %>
|
1
|
+
<h2>Sign Up</h2>
|
2
|
+
|
3
|
+
<%= form_for(@user, :url => do_user_sign_up_url) do |user| %>
|
4
|
+
<%= render "mtwarden/account/users/form", :user => user %>
|
5
|
+
<%= user.submit "Sign up" %>
|
6
|
+
<% end %>
|
@@ -1,20 +1,20 @@
|
|
1
|
-
<h2>Sign Up</h2>
|
2
|
-
|
3
|
-
<%= form_for(@account) do |account| %>
|
4
|
-
<%= account.error_messages %>
|
5
|
-
<p>
|
6
|
-
<%= account.label :name %><br>
|
7
|
-
<%= account.text_field :name %>
|
8
|
-
</p>
|
9
|
-
|
10
|
-
<p>
|
11
|
-
<%= account.label :subdomain %><br>
|
12
|
-
<%= account.text_field :subdomain %>
|
13
|
-
</p>
|
14
|
-
|
15
|
-
<%= account.fields_for :owner do |owner| %>
|
16
|
-
<%= render "mtwarden/account/users/form", :user => owner %>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<%= account.submit %>
|
20
|
-
<% end %>
|
1
|
+
<h2>Sign Up</h2>
|
2
|
+
|
3
|
+
<%= form_for(@account) do |account| %>
|
4
|
+
<%= account.error_messages %>
|
5
|
+
<p>
|
6
|
+
<%= account.label :name %><br>
|
7
|
+
<%= account.text_field :name %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<%= account.label :subdomain %><br>
|
12
|
+
<%= account.text_field :subdomain %>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
<%= account.fields_for :owner do |owner| %>
|
16
|
+
<%= render "mtwarden/account/users/form", :user => owner %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= account.submit %>
|
20
|
+
<% end %>
|
@@ -1 +1 @@
|
|
1
|
-
<%= link_to "Account Sign Up", sign_up_path %>
|
1
|
+
<%= link_to "Account Sign Up", sign_up_path %>
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<% if user_signed_in? %>
|
2
|
-
Signed in as <%= current_user.email %>
|
3
|
-
<% if owner? %>
|
4
|
-
·
|
5
|
-
<%= link_to "Edit Account", account_path %>
|
6
|
-
<% end %>
|
7
|
-
<% end %>
|
1
|
+
<% if user_signed_in? %>
|
2
|
+
Signed in as <%= current_user.email %>
|
3
|
+
<% if owner? %>
|
4
|
+
·
|
5
|
+
<%= link_to "Edit Account", account_path %>
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
@@ -1,18 +1,18 @@
|
|
1
|
-
Warden::Strategies.add(:password) do
|
2
|
-
|
3
|
-
def subdomain
|
4
|
-
ActionDispatch::Http::URL.extract_subdomains(request.host, 1)
|
5
|
-
end
|
6
|
-
|
7
|
-
def valid?
|
8
|
-
subdomain.present? && params["user"]
|
9
|
-
end
|
10
|
-
|
11
|
-
def authenticate!
|
12
|
-
return fail! unless account = Mtwarden::Account.find_by(subdomain: subdomain)
|
13
|
-
return fail! unless user = account.users.find_by(email: params["user"]["email"])
|
14
|
-
return fail! unless user.authenticate(params["user"]["password"])
|
15
|
-
success! user
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
1
|
+
Warden::Strategies.add(:password) do
|
2
|
+
|
3
|
+
def subdomain
|
4
|
+
ActionDispatch::Http::URL.extract_subdomains(request.host, 1)
|
5
|
+
end
|
6
|
+
|
7
|
+
def valid?
|
8
|
+
subdomain.present? && params["user"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def authenticate!
|
12
|
+
return fail! unless account = Mtwarden::Account.find_by(subdomain: subdomain)
|
13
|
+
return fail! unless user = account.users.find_by(email: params["user"]["email"])
|
14
|
+
return fail! unless user.authenticate(params["user"]["password"])
|
15
|
+
success! user
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
require "mtwarden/constraints/subdomain_required"
|
2
|
-
|
3
|
-
Mtwarden::Engine.routes.draw do
|
4
|
-
|
5
|
-
constraints(Mtwarden::Constraints::SubdomainRequired) do
|
6
|
-
scope :module => "account" do
|
7
|
-
root :to => "dashboard#index", :as => :account_root
|
8
|
-
get "/sign_in", :to => "sessions#new", :as => :sign_in
|
9
|
-
post "/sign_in", :to => "sessions#create", :as => :sessions
|
10
|
-
get "/sign_up", :to => "users#new", :as => :user_sign_up
|
11
|
-
post "/sign_up", :to => "users#create", :as => :do_user_sign_up
|
12
|
-
get "/account", :to => "accounts#edit", :as => :edit_account
|
13
|
-
patch "/account", :to => "accounts#update"
|
14
|
-
get "/account/plan/:plan_id",
|
15
|
-
:to => "accounts#plan",
|
16
|
-
:as => :plan_account
|
17
|
-
get "/account/subscribe",
|
18
|
-
:to => "accounts#subscribe",
|
19
|
-
:as => :subscribe_account
|
20
|
-
post "/account/confirm_plan",
|
21
|
-
:to => "accounts#confirm_plan",
|
22
|
-
:as => :confirm_plan_account
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
root "dashboard#index"
|
27
|
-
get "/sign_up", :to => "accounts#new", :as => :sign_up
|
28
|
-
post "/accounts", :to => "accounts#create", :as => :accounts
|
29
|
-
|
30
|
-
end
|
1
|
+
require "mtwarden/constraints/subdomain_required"
|
2
|
+
|
3
|
+
Mtwarden::Engine.routes.draw do
|
4
|
+
|
5
|
+
constraints(Mtwarden::Constraints::SubdomainRequired) do
|
6
|
+
scope :module => "account" do
|
7
|
+
root :to => "dashboard#index", :as => :account_root
|
8
|
+
get "/sign_in", :to => "sessions#new", :as => :sign_in
|
9
|
+
post "/sign_in", :to => "sessions#create", :as => :sessions
|
10
|
+
get "/sign_up", :to => "users#new", :as => :user_sign_up
|
11
|
+
post "/sign_up", :to => "users#create", :as => :do_user_sign_up
|
12
|
+
get "/account", :to => "accounts#edit", :as => :edit_account
|
13
|
+
patch "/account", :to => "accounts#update"
|
14
|
+
get "/account/plan/:plan_id",
|
15
|
+
:to => "accounts#plan",
|
16
|
+
:as => :plan_account
|
17
|
+
get "/account/subscribe",
|
18
|
+
:to => "accounts#subscribe",
|
19
|
+
:as => :subscribe_account
|
20
|
+
post "/account/confirm_plan",
|
21
|
+
:to => "accounts#confirm_plan",
|
22
|
+
:as => :confirm_plan_account
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
root "dashboard#index"
|
27
|
+
get "/sign_up", :to => "accounts#new", :as => :sign_up
|
28
|
+
post "/accounts", :to => "accounts#create", :as => :accounts
|
29
|
+
|
30
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class CreateMtwardenAccounts < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
create_table :mtwarden_accounts do |t|
|
4
|
-
|
5
|
-
t.string :name
|
6
|
-
|
7
|
-
t.timestamps
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
1
|
+
class CreateMtwardenAccounts < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :mtwarden_accounts do |t|
|
4
|
+
|
5
|
+
t.string :name
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class AddOwnerIdToMtwardenAccounts < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
|
4
|
-
add_column :mtwarden_accounts, :owner_id, :integer
|
5
|
-
|
6
|
-
end
|
7
|
-
end
|
1
|
+
class AddOwnerIdToMtwardenAccounts < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
|
4
|
+
add_column :mtwarden_accounts, :owner_id, :integer
|
5
|
+
|
6
|
+
end
|
7
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
class CreateMtwardenUsers < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
create_table :mtwarden_users do |t|
|
4
|
-
|
5
|
-
t.string :email
|
6
|
-
t.string :password_digest
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
class CreateMtwardenUsers < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :mtwarden_users do |t|
|
4
|
+
|
5
|
+
t.string :email
|
6
|
+
t.string :password_digest
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
class CreateMtwardenMembers < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
create_table :mtwarden_members do |t|
|
4
|
-
|
5
|
-
t.integer :account_id
|
6
|
-
t.integer :user_id
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
1
|
+
class CreateMtwardenMembers < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :mtwarden_members do |t|
|
4
|
+
|
5
|
+
t.integer :account_id
|
6
|
+
t.integer :user_id
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class AddSubdomainToMtwardenAccounts < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
|
4
|
-
add_column :mtwarden_accounts, :subdomain, :string
|
5
|
-
add_index :mtwarden_accounts, :subdomain
|
6
|
-
|
7
|
-
end
|
8
|
-
end
|
1
|
+
class AddSubdomainToMtwardenAccounts < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
|
4
|
+
add_column :mtwarden_accounts, :subdomain, :string
|
5
|
+
add_index :mtwarden_accounts, :subdomain
|
6
|
+
|
7
|
+
end
|
8
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
class CreateMtwardenPlans < ActiveRecord::Migration[5.0]
|
2
|
-
def change
|
3
|
-
create_table :mtwarden_plans do |t|
|
4
|
-
|
5
|
-
t.string :name
|
6
|
-
t.float :price
|
7
|
-
t.string :braintree_id
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
class CreateMtwardenPlans < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :mtwarden_plans do |t|
|
4
|
+
|
5
|
+
t.string :name
|
6
|
+
t.float :price
|
7
|
+
t.string :braintree_id
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|