mtdevise 5.0.0 → 5.0.1
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 +90 -90
- data/Rakefile +33 -33
- data/app/assets/config/mtdevise_manifest.js +2 -2
- data/app/assets/javascripts/mtdevise/application.js +2 -2
- data/app/assets/stylesheets/mtdevise/application.scss +2 -2
- data/app/controllers/mtdevise/account/dashboard_controller.rb +14 -14
- data/app/controllers/mtdevise/account/users_controller.rb +32 -32
- data/app/controllers/mtdevise/accounts_controller.rb +63 -63
- data/app/controllers/mtdevise/application_controller.rb +63 -63
- data/app/controllers/mtdevise/dashboard_controller.rb +14 -14
- data/app/controllers/mtdevise/welcome_controller.rb +11 -11
- data/app/extenders/controllers/application_controller_extender.rb +8 -8
- data/app/extenders/mtdevise/constraints/subdomain_required.rb +11 -11
- data/app/helpers/mtdevise/application_helper.rb +24 -24
- data/app/jobs/mtdevise/application_job.rb +3 -3
- data/app/mailers/mtdevise/application_mailer.rb +7 -7
- data/app/models/concerns/mtdevise/user_storage.rb +12 -12
- data/app/models/mtdevise/account.rb +47 -47
- data/app/models/mtdevise/application_record.rb +4 -4
- data/app/models/mtdevise/member.rb +8 -8
- data/app/models/mtdevise/user.rb +18 -18
- data/app/views/devise/confirmations/new.html.erb +23 -23
- data/app/views/devise/mailer/confirmation_instructions.html.erb +2 -2
- data/app/views/devise/mailer/reset_password_instructions.html.erb +4 -4
- data/app/views/devise/mailer/unlock_instructions.html.erb +3 -3
- data/app/views/devise/passwords/edit.html.erb +28 -28
- data/app/views/devise/passwords/new.html.erb +23 -23
- data/app/views/devise/registrations/edit.html.erb +18 -18
- data/app/views/devise/registrations/new.html.erb +31 -31
- data/app/views/devise/sessions/new.html.erb +31 -31
- data/app/views/devise/shared/_links.html.erb +21 -21
- data/app/views/devise/unlocks/new.html.erb +25 -25
- data/app/views/layouts/mtdevise/accounts.html.erb +15 -15
- data/app/views/layouts/mtdevise/accountsindex.html.erb +15 -15
- data/app/views/layouts/mtdevise/application.html.erb +15 -15
- data/app/views/layouts/mtdevise/dashboard.html.erb +16 -16
- data/app/views/layouts/mtdevise/signin.html.erb +15 -15
- data/app/views/layouts/mtdevise/signup.html.erb +15 -15
- data/app/views/layouts/mtdevise/useredit.html.erb +15 -15
- data/app/views/layouts/mtdevise/welcome.html.erb +15 -15
- data/app/views/mtdevise/account/dashboard/index.html.erb +1 -1
- data/app/views/mtdevise/account/sessions/new.html.erb +15 -15
- data/app/views/mtdevise/account/users/_form.html.erb +11 -11
- data/app/views/mtdevise/account/users/new.html.erb +5 -5
- data/app/views/mtdevise/accounts/index.html.erb +30 -30
- data/app/views/mtdevise/accounts/new.html.erb +80 -80
- data/app/views/mtdevise/dashboard/index.html.erb +1 -1
- data/app/views/mtdevise/welcome/index.html.erb +18 -18
- data/app/views/shared/_flash.html.erb +10 -10
- data/app/views/shared/_header.html.erb +19 -19
- data/app/views/shared/_validation.html.erb +10 -10
- data/config/initializers/assets.rb +2 -2
- data/config/initializers/devise.rb +279 -279
- data/config/initializers/devise/strategies/subdomain.rb +26 -26
- data/config/locales/devise.en.yml +60 -60
- data/config/routes.rb +22 -22
- data/db/migrate/20150426071228_create_mtdevise_accounts.rb +11 -11
- data/db/migrate/20150426115631_add_owner_id_to_mtdevise_accounts.rb +7 -7
- data/db/migrate/20150426115910_create_mtdevise_users.rb +12 -12
- data/db/migrate/20150426143800_add_devise_to_mtdevise_users.rb +50 -50
- data/db/migrate/20150427200506_add_subdomain_to_mtdevise_accounts.rb +8 -8
- data/db/migrate/20150428110406_create_mtdevise_members.rb +12 -12
- data/db/migrate/20150504181830_add_confirmed_at_to_users.rb +10 -10
- data/db/migrate/20150719125100_add_authentication_token_to_mtdevise_users.rb +8 -8
- data/db/migrate/20151231043439_add_firstname_to_mtdevise_accounts.rb +9 -9
- data/lib/generators/mtdevise/views_generator.rb +60 -60
- data/lib/mtdevise.rb +4 -4
- data/lib/mtdevise/active_record_extensions.rb +15 -15
- data/lib/mtdevise/engine.rb +51 -51
- data/lib/mtdevise/scoped_to.rb +9 -9
- data/lib/mtdevise/version.rb +3 -3
- data/lib/tasks/mtdevise_tasks.rake +4 -4
- data/lib/templates/erb/scaffold/_form.html.erb +15 -15
- metadata +50 -8
@@ -1,63 +1,63 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
|
3
|
-
class ApplicationController < ::ApplicationController
|
4
|
-
|
5
|
-
# Secirity and Filters
|
6
|
-
protect_from_forgery with: :null_session
|
7
|
-
before_action :check_subdomain
|
8
|
-
|
9
|
-
# Omniauth
|
10
|
-
def after_sign_in_path_for(resource)
|
11
|
-
request.env['omniauth.origin'] || stored_location_for(resource) || mtdevise.accounts_path
|
12
|
-
end
|
13
|
-
|
14
|
-
# Helpers for Current Account and Users
|
15
|
-
def current_user?(user)
|
16
|
-
user == current_user
|
17
|
-
end
|
18
|
-
helper_method :current_user
|
19
|
-
|
20
|
-
def current_account?(account)
|
21
|
-
account == current_account
|
22
|
-
end
|
23
|
-
helper_method :current_account
|
24
|
-
|
25
|
-
# Load Helpers
|
26
|
-
helper Phctitleseo::Engine.helpers
|
27
|
-
helper Phcnotifi::Engine.helpers
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
# Logged in redirect
|
32
|
-
def redirect_logged_in_users_to_account_page
|
33
|
-
redirect_to mtdevise.accounts_path if user_signed_in?
|
34
|
-
end
|
35
|
-
|
36
|
-
# Subdomain Checker
|
37
|
-
def check_subdomain
|
38
|
-
if request.subdomain.present? && Account.where(subdomain: request.subdomain).blank?
|
39
|
-
redirect_to mtdevise.root_url(subdomain: false), notice: "Subdomain Doesn't Exist. Would you like to Register."
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Resolve Layouts for Custom Account Actions
|
44
|
-
def layouts_resolver_accounts
|
45
|
-
case action_name
|
46
|
-
when "index"
|
47
|
-
"layouts/mtdevise/accountsindex"
|
48
|
-
when "new"
|
49
|
-
"layouts/mtdevise/signup"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Resolve Layouts for Custom User Actions
|
54
|
-
def layouts_resolver_users
|
55
|
-
case action_name
|
56
|
-
when "new"
|
57
|
-
"layouts/mtdevise/signup"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
|
3
|
+
class ApplicationController < ::ApplicationController
|
4
|
+
|
5
|
+
# Secirity and Filters
|
6
|
+
protect_from_forgery with: :null_session
|
7
|
+
before_action :check_subdomain
|
8
|
+
|
9
|
+
# Omniauth
|
10
|
+
def after_sign_in_path_for(resource)
|
11
|
+
request.env['omniauth.origin'] || stored_location_for(resource) || mtdevise.accounts_path
|
12
|
+
end
|
13
|
+
|
14
|
+
# Helpers for Current Account and Users
|
15
|
+
def current_user?(user)
|
16
|
+
user == current_user
|
17
|
+
end
|
18
|
+
helper_method :current_user
|
19
|
+
|
20
|
+
def current_account?(account)
|
21
|
+
account == current_account
|
22
|
+
end
|
23
|
+
helper_method :current_account
|
24
|
+
|
25
|
+
# Load Helpers
|
26
|
+
helper Phctitleseo::Engine.helpers
|
27
|
+
helper Phcnotifi::Engine.helpers
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
# Logged in redirect
|
32
|
+
def redirect_logged_in_users_to_account_page
|
33
|
+
redirect_to mtdevise.accounts_path if user_signed_in?
|
34
|
+
end
|
35
|
+
|
36
|
+
# Subdomain Checker
|
37
|
+
def check_subdomain
|
38
|
+
if request.subdomain.present? && Account.where(subdomain: request.subdomain).blank?
|
39
|
+
redirect_to mtdevise.root_url(subdomain: false), notice: "Subdomain Doesn't Exist. Would you like to Register."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Resolve Layouts for Custom Account Actions
|
44
|
+
def layouts_resolver_accounts
|
45
|
+
case action_name
|
46
|
+
when "index"
|
47
|
+
"layouts/mtdevise/accountsindex"
|
48
|
+
when "new"
|
49
|
+
"layouts/mtdevise/signup"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Resolve Layouts for Custom User Actions
|
54
|
+
def layouts_resolver_users
|
55
|
+
case action_name
|
56
|
+
when "new"
|
57
|
+
"layouts/mtdevise/signup"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require_dependency "mtdevise/application_controller"
|
2
|
-
|
3
|
-
module Mtdevise
|
4
|
-
class DashboardController < ApplicationController
|
5
|
-
|
6
|
-
# Filters and
|
7
|
-
before_action :authenticate_user!
|
8
|
-
layout "mtdevise/dashboard"
|
9
|
-
|
10
|
-
# Define Dashboard Frontend Index
|
11
|
-
def index
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
1
|
+
require_dependency "mtdevise/application_controller"
|
2
|
+
|
3
|
+
module Mtdevise
|
4
|
+
class DashboardController < ApplicationController
|
5
|
+
|
6
|
+
# Filters and
|
7
|
+
before_action :authenticate_user!
|
8
|
+
layout "mtdevise/dashboard"
|
9
|
+
|
10
|
+
# Define Dashboard Frontend Index
|
11
|
+
def index
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
15
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require_dependency "mtdevise/application_controller"
|
2
|
-
|
3
|
-
module Mtdevise
|
4
|
-
class WelcomeController < ApplicationController
|
5
|
-
layout "mtdevise/welcome"
|
6
|
-
before_action :authenticate_user!, except: [:index]
|
7
|
-
before_action :redirect_logged_in_users_to_account_page
|
8
|
-
|
9
|
-
def index
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require_dependency "mtdevise/application_controller"
|
2
|
+
|
3
|
+
module Mtdevise
|
4
|
+
class WelcomeController < ApplicationController
|
5
|
+
layout "mtdevise/welcome"
|
6
|
+
before_action :authenticate_user!, except: [:index]
|
7
|
+
before_action :redirect_logged_in_users_to_account_page
|
8
|
+
|
9
|
+
def index
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
::ApplicationController.class_eval do
|
2
|
-
|
3
|
-
# Current Account Helper
|
4
|
-
def current_account
|
5
|
-
@current_account ||= env['Houser-Object']
|
6
|
-
end
|
7
|
-
helper_method :current_account
|
8
|
-
|
1
|
+
::ApplicationController.class_eval do
|
2
|
+
|
3
|
+
# Current Account Helper
|
4
|
+
def current_account
|
5
|
+
@current_account ||= env['Houser-Object']
|
6
|
+
end
|
7
|
+
helper_method :current_account
|
8
|
+
|
9
9
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
module Constraints
|
3
|
-
class SubdomainRequired
|
4
|
-
|
5
|
-
# Subdomain Matching
|
6
|
-
def self.matches?(request)
|
7
|
-
request.subdomain.present? && request.subdomain != "www" && request.subdomain != ENV['DEPLOYED_DOMAIN']
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
module Constraints
|
3
|
+
class SubdomainRequired
|
4
|
+
|
5
|
+
# Subdomain Matching
|
6
|
+
def self.matches?(request)
|
7
|
+
request.subdomain.present? && request.subdomain != "www" && request.subdomain != ENV['DEPLOYED_DOMAIN']
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
module ApplicationHelper
|
3
|
-
|
4
|
-
# Helper for Page Title
|
5
|
-
def phc_title(phc_page_title)
|
6
|
-
content_for :phc_title, phc_page_title.to_s
|
7
|
-
end
|
8
|
-
|
9
|
-
# Helper for Page Title Tag
|
10
|
-
def phc_title_tagline(phc_page_title_tagline)
|
11
|
-
content_for :phc_title_tagline, phc_page_title_tagline.to_s
|
12
|
-
end
|
13
|
-
|
14
|
-
# Bootstrap Notification System
|
15
|
-
def flash_class(level)
|
16
|
-
case level.to_sym
|
17
|
-
when :notice then "alert alert-info"
|
18
|
-
when :success then "alert alert-success"
|
19
|
-
when :error then "alert alert-danger"
|
20
|
-
when :alert then "alert alert-warning"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
module ApplicationHelper
|
3
|
+
|
4
|
+
# Helper for Page Title
|
5
|
+
def phc_title(phc_page_title)
|
6
|
+
content_for :phc_title, phc_page_title.to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
# Helper for Page Title Tag
|
10
|
+
def phc_title_tagline(phc_page_title_tagline)
|
11
|
+
content_for :phc_title_tagline, phc_page_title_tagline.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
# Bootstrap Notification System
|
15
|
+
def flash_class(level)
|
16
|
+
case level.to_sym
|
17
|
+
when :notice then "alert alert-info"
|
18
|
+
when :success then "alert alert-success"
|
19
|
+
when :error then "alert alert-danger"
|
20
|
+
when :alert then "alert alert-warning"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
class ApplicationJob < ActiveJob::Base
|
3
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
class ApplicationJob < ActiveJob::Base
|
3
|
+
end
|
4
4
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
class ApplicationMailer < ActionMailer::Base
|
3
|
-
|
4
|
-
default from: 'from@example.com'
|
5
|
-
layout 'mailer'
|
6
|
-
|
7
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
class ApplicationMailer < ActionMailer::Base
|
3
|
+
|
4
|
+
default from: 'from@example.com'
|
5
|
+
layout 'mailer'
|
6
|
+
|
7
|
+
end
|
8
8
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
module UserStorage
|
3
|
-
|
4
|
-
# Extend Additional Account Support
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
# Find User Table
|
8
|
-
included do
|
9
|
-
self.table_name = "mtdevise_users"
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
module UserStorage
|
3
|
+
|
4
|
+
# Extend Additional Account Support
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# Find User Table
|
8
|
+
included do
|
9
|
+
self.table_name = "mtdevise_users"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
13
|
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
class Account < ActiveRecord::Base
|
3
|
-
|
4
|
-
# Relationships
|
5
|
-
belongs_to :owner, :class_name => "Mtdevise::User"
|
6
|
-
has_many :members, :class_name => "Mtdevise::Member"
|
7
|
-
has_many :users, :through => :members
|
8
|
-
|
9
|
-
accepts_nested_attributes_for :owner
|
10
|
-
|
11
|
-
# Form Validations
|
12
|
-
validates :subdomain,
|
13
|
-
presence: true,
|
14
|
-
uniqueness: true,
|
15
|
-
format: { with: /\A[\w\-]+\Z/i, message: 'is not allowed. Please choose another subdomain.'},
|
16
|
-
exclusion: { in: %w(admin), message: 'is not allowed. Please choose another subdomain.'}
|
17
|
-
|
18
|
-
validates :name,
|
19
|
-
presence: true,
|
20
|
-
uniqueness: {scope: :owner_id}
|
21
|
-
|
22
|
-
validates :firstname,
|
23
|
-
presence: true
|
24
|
-
|
25
|
-
validates :lastname,
|
26
|
-
presence: true
|
27
|
-
|
28
|
-
validates :username,
|
29
|
-
presence: true,
|
30
|
-
uniqueness: true
|
31
|
-
|
32
|
-
before_validation do
|
33
|
-
self.subdomain = subdomain.to_s.downcase
|
34
|
-
self.username = username.to_s.downcase
|
35
|
-
end
|
36
|
-
|
37
|
-
# Define Account/Owner for User
|
38
|
-
def self.create_with_owner(params={})
|
39
|
-
account = new(params)
|
40
|
-
if account.save
|
41
|
-
account.users << account.owner
|
42
|
-
account.owner.confirm
|
43
|
-
end
|
44
|
-
account
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
class Account < ActiveRecord::Base
|
3
|
+
|
4
|
+
# Relationships
|
5
|
+
belongs_to :owner, :class_name => "Mtdevise::User"
|
6
|
+
has_many :members, :class_name => "Mtdevise::Member"
|
7
|
+
has_many :users, :through => :members
|
8
|
+
|
9
|
+
accepts_nested_attributes_for :owner
|
10
|
+
|
11
|
+
# Form Validations
|
12
|
+
validates :subdomain,
|
13
|
+
presence: true,
|
14
|
+
uniqueness: true,
|
15
|
+
format: { with: /\A[\w\-]+\Z/i, message: 'is not allowed. Please choose another subdomain.'},
|
16
|
+
exclusion: { in: %w(admin), message: 'is not allowed. Please choose another subdomain.'}
|
17
|
+
|
18
|
+
validates :name,
|
19
|
+
presence: true,
|
20
|
+
uniqueness: {scope: :owner_id}
|
21
|
+
|
22
|
+
validates :firstname,
|
23
|
+
presence: true
|
24
|
+
|
25
|
+
validates :lastname,
|
26
|
+
presence: true
|
27
|
+
|
28
|
+
validates :username,
|
29
|
+
presence: true,
|
30
|
+
uniqueness: true
|
31
|
+
|
32
|
+
before_validation do
|
33
|
+
self.subdomain = subdomain.to_s.downcase
|
34
|
+
self.username = username.to_s.downcase
|
35
|
+
end
|
36
|
+
|
37
|
+
# Define Account/Owner for User
|
38
|
+
def self.create_with_owner(params={})
|
39
|
+
account = new(params)
|
40
|
+
if account.save
|
41
|
+
account.users << account.owner
|
42
|
+
account.owner.confirm
|
43
|
+
end
|
44
|
+
account
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
48
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
class ApplicationRecord < ActiveRecord::Base
|
3
|
-
self.abstract_class = true
|
4
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
class ApplicationRecord < ActiveRecord::Base
|
3
|
+
self.abstract_class = true
|
4
|
+
end
|
5
5
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Mtdevise
|
2
|
-
class Member < ActiveRecord::Base
|
3
|
-
|
4
|
-
# Relationships
|
5
|
-
belongs_to :account, :class_name => "Mtdevise::Account"
|
6
|
-
belongs_to :user, :class_name => "Mtdevise::User"
|
7
|
-
|
8
|
-
end
|
1
|
+
module Mtdevise
|
2
|
+
class Member < ActiveRecord::Base
|
3
|
+
|
4
|
+
# Relationships
|
5
|
+
belongs_to :account, :class_name => "Mtdevise::Account"
|
6
|
+
belongs_to :user, :class_name => "Mtdevise::User"
|
7
|
+
|
8
|
+
end
|
9
9
|
end
|