mtdevise 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/README.md +90 -90
  4. data/Rakefile +33 -33
  5. data/app/assets/config/mtdevise_manifest.js +2 -2
  6. data/app/assets/javascripts/mtdevise/application.js +2 -2
  7. data/app/assets/stylesheets/mtdevise/application.scss +2 -2
  8. data/app/controllers/mtdevise/account/dashboard_controller.rb +14 -14
  9. data/app/controllers/mtdevise/account/users_controller.rb +32 -32
  10. data/app/controllers/mtdevise/accounts_controller.rb +63 -63
  11. data/app/controllers/mtdevise/application_controller.rb +63 -63
  12. data/app/controllers/mtdevise/dashboard_controller.rb +14 -14
  13. data/app/controllers/mtdevise/welcome_controller.rb +11 -11
  14. data/app/extenders/controllers/application_controller_extender.rb +8 -8
  15. data/app/extenders/mtdevise/constraints/subdomain_required.rb +11 -11
  16. data/app/helpers/mtdevise/application_helper.rb +24 -24
  17. data/app/jobs/mtdevise/application_job.rb +3 -3
  18. data/app/mailers/mtdevise/application_mailer.rb +7 -7
  19. data/app/models/concerns/mtdevise/user_storage.rb +12 -12
  20. data/app/models/mtdevise/account.rb +47 -47
  21. data/app/models/mtdevise/application_record.rb +4 -4
  22. data/app/models/mtdevise/member.rb +8 -8
  23. data/app/models/mtdevise/user.rb +18 -18
  24. data/app/views/devise/confirmations/new.html.erb +23 -23
  25. data/app/views/devise/mailer/confirmation_instructions.html.erb +2 -2
  26. data/app/views/devise/mailer/reset_password_instructions.html.erb +4 -4
  27. data/app/views/devise/mailer/unlock_instructions.html.erb +3 -3
  28. data/app/views/devise/passwords/edit.html.erb +28 -28
  29. data/app/views/devise/passwords/new.html.erb +23 -23
  30. data/app/views/devise/registrations/edit.html.erb +18 -18
  31. data/app/views/devise/registrations/new.html.erb +31 -31
  32. data/app/views/devise/sessions/new.html.erb +31 -31
  33. data/app/views/devise/shared/_links.html.erb +21 -21
  34. data/app/views/devise/unlocks/new.html.erb +25 -25
  35. data/app/views/layouts/mtdevise/accounts.html.erb +15 -15
  36. data/app/views/layouts/mtdevise/accountsindex.html.erb +15 -15
  37. data/app/views/layouts/mtdevise/application.html.erb +15 -15
  38. data/app/views/layouts/mtdevise/dashboard.html.erb +16 -16
  39. data/app/views/layouts/mtdevise/signin.html.erb +15 -15
  40. data/app/views/layouts/mtdevise/signup.html.erb +15 -15
  41. data/app/views/layouts/mtdevise/useredit.html.erb +15 -15
  42. data/app/views/layouts/mtdevise/welcome.html.erb +15 -15
  43. data/app/views/mtdevise/account/dashboard/index.html.erb +1 -1
  44. data/app/views/mtdevise/account/sessions/new.html.erb +15 -15
  45. data/app/views/mtdevise/account/users/_form.html.erb +11 -11
  46. data/app/views/mtdevise/account/users/new.html.erb +5 -5
  47. data/app/views/mtdevise/accounts/index.html.erb +30 -30
  48. data/app/views/mtdevise/accounts/new.html.erb +80 -80
  49. data/app/views/mtdevise/dashboard/index.html.erb +1 -1
  50. data/app/views/mtdevise/welcome/index.html.erb +18 -18
  51. data/app/views/shared/_flash.html.erb +10 -10
  52. data/app/views/shared/_header.html.erb +19 -19
  53. data/app/views/shared/_validation.html.erb +10 -10
  54. data/config/initializers/assets.rb +2 -2
  55. data/config/initializers/devise.rb +279 -279
  56. data/config/initializers/devise/strategies/subdomain.rb +26 -26
  57. data/config/locales/devise.en.yml +60 -60
  58. data/config/routes.rb +22 -22
  59. data/db/migrate/20150426071228_create_mtdevise_accounts.rb +11 -11
  60. data/db/migrate/20150426115631_add_owner_id_to_mtdevise_accounts.rb +7 -7
  61. data/db/migrate/20150426115910_create_mtdevise_users.rb +12 -12
  62. data/db/migrate/20150426143800_add_devise_to_mtdevise_users.rb +50 -50
  63. data/db/migrate/20150427200506_add_subdomain_to_mtdevise_accounts.rb +8 -8
  64. data/db/migrate/20150428110406_create_mtdevise_members.rb +12 -12
  65. data/db/migrate/20150504181830_add_confirmed_at_to_users.rb +10 -10
  66. data/db/migrate/20150719125100_add_authentication_token_to_mtdevise_users.rb +8 -8
  67. data/db/migrate/20151231043439_add_firstname_to_mtdevise_accounts.rb +9 -9
  68. data/lib/generators/mtdevise/views_generator.rb +60 -60
  69. data/lib/mtdevise.rb +4 -4
  70. data/lib/mtdevise/active_record_extensions.rb +15 -15
  71. data/lib/mtdevise/engine.rb +51 -51
  72. data/lib/mtdevise/scoped_to.rb +9 -9
  73. data/lib/mtdevise/version.rb +3 -3
  74. data/lib/tasks/mtdevise_tasks.rake +4 -4
  75. data/lib/templates/erb/scaffold/_form.html.erb +15 -15
  76. metadata +50 -8
@@ -1,26 +1,26 @@
1
- require 'devise/strategies/authenticatable'
2
-
3
- module Devise
4
- module Strategies
5
- class SubdomainLogin < Authenticatable
6
-
7
- def subdomain
8
- request.subdomain
9
- end
10
-
11
- def valid?
12
- subdomain.present? && params["user"]
13
- end
14
-
15
- def authenticate!
16
- return fail!('Invalid email or password.') unless account = Mtdevise::Account.find_by(subdomain: subdomain)
17
- return fail!('Invalid email or password.') unless user = account.users.find_by(email: params["user"]["email"])
18
- return fail!('Invalid email or password.') unless user.valid_password?(params["user"]["password"])
19
- success! user
20
- end
21
-
22
- end
23
- end
24
- end
25
-
26
- Warden::Strategies.add(:subdomain_login, Devise::Strategies::SubdomainLogin)
1
+ require 'devise/strategies/authenticatable'
2
+
3
+ module Devise
4
+ module Strategies
5
+ class SubdomainLogin < Authenticatable
6
+
7
+ def subdomain
8
+ request.subdomain
9
+ end
10
+
11
+ def valid?
12
+ subdomain.present? && params["user"]
13
+ end
14
+
15
+ def authenticate!
16
+ return fail!('Invalid email or password.') unless account = Mtdevise::Account.find_by(subdomain: subdomain)
17
+ return fail!('Invalid email or password.') unless user = account.users.find_by(email: params["user"]["email"])
18
+ return fail!('Invalid email or password.') unless user.valid_password?(params["user"]["password"])
19
+ success! user
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
26
+ Warden::Strategies.add(:subdomain_login, Devise::Strategies::SubdomainLogin)
@@ -1,60 +1,60 @@
1
- # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
-
3
- en:
4
- devise:
5
- confirmations:
6
- confirmed: "Your email address has been successfully confirmed."
7
- send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
- send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
- failure:
10
- already_authenticated: "You are already signed in."
11
- inactive: "Your account is not activated yet."
12
- invalid: "Invalid email or password."
13
- locked: "Your account is locked."
14
- last_attempt: "You have one more attempt before your account is locked."
15
- not_found_in_database: "Invalid %{authentication_keys} or password."
16
- timeout: "Your session expired. Please sign in again to continue."
17
- unauthenticated: "You need to sign in or sign up before continuing."
18
- unconfirmed: "You have to confirm your email address before continuing."
19
- mailer:
20
- confirmation_instructions:
21
- subject: "Confirmation instructions"
22
- reset_password_instructions:
23
- subject: "Reset password instructions"
24
- unlock_instructions:
25
- subject: "Unlock instructions"
26
- omniauth_callbacks:
27
- failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
- success: "Successfully authenticated from %{kind} account."
29
- passwords:
30
- no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31
- send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
32
- send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
- updated: "Your password has been changed successfully. You are now signed in."
34
- updated_not_active: "Your password has been changed successfully."
35
- registrations:
36
- destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
37
- signed_up: "Welcome! You have signed up successfully."
38
- signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39
- signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40
- signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
41
- update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
42
- updated: "Your account has been updated successfully."
43
- sessions:
44
- signed_in: "Signed in successfully."
45
- signed_out: "Signed out successfully."
46
- already_signed_out: "Signed out successfully."
47
- unlocks:
48
- send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
49
- send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
50
- unlocked: "Your account has been unlocked successfully. Please sign in to continue."
51
- errors:
52
- messages:
53
- already_confirmed: "was already confirmed, please try signing in"
54
- confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
55
- expired: "has expired, please request a new one"
56
- not_found: "not found"
57
- not_locked: "was not locked"
58
- not_saved:
59
- one: "1 error prohibited this %{resource} from being saved:"
60
- other: "%{count} errors prohibited this %{resource} from being saved:"
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your email address has been successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid email or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account is locked."
15
+ not_found_in_database: "Invalid %{authentication_keys} or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your email address before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock instructions"
26
+ omniauth_callbacks:
27
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
+ success: "Successfully authenticated from %{kind} account."
29
+ passwords:
30
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
32
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
+ updated: "Your password has been changed successfully. You are now signed in."
34
+ updated_not_active: "Your password has been changed successfully."
35
+ registrations:
36
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
37
+ signed_up: "Welcome! You have signed up successfully."
38
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
41
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
42
+ updated: "Your account has been updated successfully."
43
+ sessions:
44
+ signed_in: "Signed in successfully."
45
+ signed_out: "Signed out successfully."
46
+ already_signed_out: "Signed out successfully."
47
+ unlocks:
48
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
49
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
50
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
51
+ errors:
52
+ messages:
53
+ already_confirmed: "was already confirmed, please try signing in"
54
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
55
+ expired: "has expired, please request a new one"
56
+ not_found: "not found"
57
+ not_locked: "was not locked"
58
+ not_saved:
59
+ one: "1 error prohibited this %{resource} from being saved:"
60
+ other: "%{count} errors prohibited this %{resource} from being saved:"
@@ -1,22 +1,22 @@
1
- require 'mtdevise/constraints/subdomain_required'
2
-
3
- Mtdevise::Engine.routes.draw do
4
-
5
- # Backend User Routes
6
- constraints(Mtdevise::Constraints::SubdomainRequired) do
7
- scope :module => "account" do
8
- root :to => "dashboard#index", :as => :account_root
9
- # get "/sign_in", :to => "sessions#new"
10
- # post "/sign_in", :to => "sessions#create", :as => :sessions
11
- get "/sign_up", :to => "users#new", :as => :user_sign_up
12
- post "/sign_up", :to => "users#create", :as => :do_user_sign_up
13
- end
14
- end
15
-
16
- # FrontEnd User Routes
17
- devise_for :users, class_name: 'Mtdevise::User', module: :devise
18
- get '/sign_up', :to => 'accounts#new', :as => :sign_up
19
- resources :accounts, only: [:create, :index, :new]
20
- root 'welcome#index'
21
-
22
- end
1
+ require 'mtdevise/constraints/subdomain_required'
2
+
3
+ Mtdevise::Engine.routes.draw do
4
+
5
+ # Backend User Routes
6
+ constraints(Mtdevise::Constraints::SubdomainRequired) do
7
+ scope :module => "account" do
8
+ root :to => "dashboard#index", :as => :account_root
9
+ # get "/sign_in", :to => "sessions#new"
10
+ # post "/sign_in", :to => "sessions#create", :as => :sessions
11
+ get "/sign_up", :to => "users#new", :as => :user_sign_up
12
+ post "/sign_up", :to => "users#create", :as => :do_user_sign_up
13
+ end
14
+ end
15
+
16
+ # FrontEnd User Routes
17
+ devise_for :users, class_name: 'Mtdevise::User', module: :devise
18
+ get '/sign_up', :to => 'accounts#new', :as => :sign_up
19
+ resources :accounts, only: [:create, :index, :new]
20
+ root 'welcome#index'
21
+
22
+ end
@@ -1,11 +1,11 @@
1
- class CreateMtdeviseAccounts < ActiveRecord::Migration[5.0]
2
- def change
3
- create_table :mtdevise_accounts do |t|
4
-
5
- t.string :name
6
-
7
- t.timestamps
8
-
9
- end
10
- end
11
- end
1
+ class CreateMtdeviseAccounts < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :mtdevise_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 AddOwnerIdToMtdeviseAccounts < ActiveRecord::Migration[5.0]
2
- def change
3
-
4
- add_column :mtdevise_accounts, :owner_id, :integer
5
-
6
- end
7
- end
1
+ class AddOwnerIdToMtdeviseAccounts < ActiveRecord::Migration[5.0]
2
+ def change
3
+
4
+ add_column :mtdevise_accounts, :owner_id, :integer
5
+
6
+ end
7
+ end
@@ -1,12 +1,12 @@
1
- class CreateMtdeviseUsers < ActiveRecord::Migration[5.0]
2
- def change
3
- create_table :mtdevise_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 CreateMtdeviseUsers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :mtdevise_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,50 +1,50 @@
1
- class AddDeviseToMtdeviseUsers < ActiveRecord::Migration[5.0]
2
-
3
- def self.up
4
- change_table(:mtdevise_users) do |t|
5
- ## Database authenticatable
6
- t.string :encrypted_password, null: false, default: ""
7
-
8
- ## Recoverable
9
- t.string :reset_password_token
10
- t.datetime :reset_password_sent_at
11
-
12
- ## Rememberable
13
- t.datetime :remember_created_at
14
-
15
- ## Trackable
16
- t.integer :sign_in_count, default: 0, null: false
17
- t.datetime :current_sign_in_at
18
- t.datetime :last_sign_in_at
19
- t.string :current_sign_in_ip
20
- t.string :last_sign_in_ip
21
-
22
- ## Confirmable
23
- # t.string :confirmation_token
24
- # t.datetime :confirmed_at
25
- # t.datetime :confirmation_sent_at
26
- # t.string :unconfirmed_email # Only if using reconfirmable
27
-
28
- ## Lockable
29
- # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
- # t.string :unlock_token # Only if unlock strategy is :email or :both
31
- # t.datetime :locked_at
32
-
33
-
34
- # Uncomment below if timestamps were not included in your original model.
35
- # t.timestamps null: false
36
- end
37
-
38
- add_index :mtdevise_users, :email, unique: true
39
- add_index :mtdevise_users, :reset_password_token, unique: true
40
- # add_index :mtdevise_users, :confirmation_token, unique: true
41
- # add_index :mtdevise_users, :unlock_token, unique: true
42
- end
43
-
44
- def self.down
45
- # By default, we don't want to make any assumption about how to roll back a migration when your
46
- # model already existed. Please edit below which fields you would like to remove in this migration.
47
- raise ActiveRecord::IrreversibleMigration
48
- end
49
-
50
- end
1
+ class AddDeviseToMtdeviseUsers < ActiveRecord::Migration[5.0]
2
+
3
+ def self.up
4
+ change_table(:mtdevise_users) do |t|
5
+ ## Database authenticatable
6
+ t.string :encrypted_password, null: false, default: ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, default: 0, null: false
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Confirmable
23
+ # t.string :confirmation_token
24
+ # t.datetime :confirmed_at
25
+ # t.datetime :confirmation_sent_at
26
+ # t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ # t.datetime :locked_at
32
+
33
+
34
+ # Uncomment below if timestamps were not included in your original model.
35
+ # t.timestamps null: false
36
+ end
37
+
38
+ add_index :mtdevise_users, :email, unique: true
39
+ add_index :mtdevise_users, :reset_password_token, unique: true
40
+ # add_index :mtdevise_users, :confirmation_token, unique: true
41
+ # add_index :mtdevise_users, :unlock_token, unique: true
42
+ end
43
+
44
+ def self.down
45
+ # By default, we don't want to make any assumption about how to roll back a migration when your
46
+ # model already existed. Please edit below which fields you would like to remove in this migration.
47
+ raise ActiveRecord::IrreversibleMigration
48
+ end
49
+
50
+ end
@@ -1,8 +1,8 @@
1
- class AddSubdomainToMtdeviseAccounts < ActiveRecord::Migration[5.0]
2
- def change
3
-
4
- add_column :mtdevise_accounts, :subdomain, :string
5
- add_index :mtdevise_accounts, :subdomain
6
-
7
- end
8
- end
1
+ class AddSubdomainToMtdeviseAccounts < ActiveRecord::Migration[5.0]
2
+ def change
3
+
4
+ add_column :mtdevise_accounts, :subdomain, :string
5
+ add_index :mtdevise_accounts, :subdomain
6
+
7
+ end
8
+ end
@@ -1,12 +1,12 @@
1
- class CreateMtdeviseMembers < ActiveRecord::Migration[5.0]
2
- def change
3
- create_table :mtdevise_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 CreateMtdeviseMembers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :mtdevise_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,10 +1,10 @@
1
- class AddConfirmedAtToUsers < ActiveRecord::Migration[5.0]
2
- def change
3
-
4
- add_column :mtdevise_users, :confirmed_at, :timestamp
5
- add_column :mtdevise_users, :confirmation_token, :string
6
- add_column :mtdevise_users, :confirmation_sent_at, :timestamp
7
- add_column :mtdevise_users, :unconfirmed_email, :string
8
-
9
- end
10
- end
1
+ class AddConfirmedAtToUsers < ActiveRecord::Migration[5.0]
2
+ def change
3
+
4
+ add_column :mtdevise_users, :confirmed_at, :timestamp
5
+ add_column :mtdevise_users, :confirmation_token, :string
6
+ add_column :mtdevise_users, :confirmation_sent_at, :timestamp
7
+ add_column :mtdevise_users, :unconfirmed_email, :string
8
+
9
+ end
10
+ end