fat_free_crm 0.18.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +61 -160
- data/.travis.yml +27 -11
- data/CHANGELOG.md +40 -24
- data/CONTRIBUTORS.md +1 -0
- data/Dockerfile +45 -14
- data/Gemfile +16 -10
- data/Gemfile.lock +230 -222
- data/Procfile +1 -1
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +1 -1
- data/app/controllers/admin/field_groups_controller.rb +1 -3
- data/app/controllers/admin/tags_controller.rb +1 -3
- data/app/controllers/admin/users_controller.rb +5 -8
- data/app/controllers/application_controller.rb +11 -45
- data/app/controllers/comments_controller.rb +2 -5
- data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
- data/app/controllers/emails_controller.rb +0 -2
- data/app/controllers/entities/accounts_controller.rb +1 -3
- data/app/controllers/entities/campaigns_controller.rb +1 -3
- data/app/controllers/entities/contacts_controller.rb +4 -24
- data/app/controllers/entities/leads_controller.rb +7 -10
- data/app/controllers/entities/opportunities_controller.rb +4 -14
- data/app/controllers/entities_controller.rb +21 -7
- data/app/controllers/home_controller.rb +2 -4
- data/app/controllers/passwords_controller.rb +3 -59
- data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
- data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
- data/app/controllers/tasks_controller.rb +8 -17
- data/app/controllers/users_controller.rb +8 -29
- data/app/helpers/admin/users_helper.rb +1 -1
- data/app/helpers/application_helper.rb +27 -32
- data/app/helpers/campaigns_helper.rb +1 -1
- data/app/helpers/contacts_helper.rb +1 -3
- data/app/helpers/opportunities_helper.rb +4 -12
- data/app/helpers/tasks_helper.rb +1 -1
- data/app/helpers/users_helper.rb +1 -3
- data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
- data/app/mailers/user_mailer.rb +0 -9
- data/app/models/entities/account.rb +10 -10
- data/app/models/entities/campaign.rb +4 -6
- data/app/models/entities/contact.rb +24 -12
- data/app/models/entities/lead.rb +7 -7
- data/app/models/entities/opportunity.rb +7 -9
- data/app/models/fields/custom_field.rb +1 -0
- data/app/models/fields/custom_field_date_pair.rb +2 -0
- data/app/models/fields/field.rb +1 -3
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +3 -7
- data/app/models/observers/lead_observer.rb +2 -4
- data/app/models/observers/opportunity_observer.rb +2 -4
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/email.rb +2 -2
- data/app/models/polymorphic/task.rb +13 -9
- data/app/models/polymorphic/version.rb +3 -2
- data/app/models/setting.rb +2 -0
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +2 -1
- data/app/models/users/user.rb +67 -42
- data/app/views/accounts/_top_section.html.haml +1 -1
- data/app/views/accounts/edit.js.haml +1 -1
- data/app/views/accounts/update.js.haml +2 -2
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/contacts/_index_brief.html.haml +1 -1
- data/app/views/contacts/_index_full.html.haml +1 -1
- data/app/views/contacts/_index_long.html.haml +1 -1
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/password_change.html.haml +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/passwords/edit.html.haml +18 -0
- data/app/views/devise/passwords/new.html.haml +10 -0
- data/app/views/devise/registrations/new.html.haml +21 -0
- data/app/views/devise/sessions/new.html.haml +32 -0
- data/app/views/layouts/_about.html.haml +5 -5
- data/app/views/layouts/_header.html.haml +3 -3
- data/app/views/layouts/admin/_header.html.haml +1 -1
- data/app/views/shared/_address.html.haml +5 -5
- data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
- data/app/views/users/_avatar.html.haml +1 -1
- data/bin/bundle +1 -1
- data/bin/rails +1 -1
- data/bin/setup +38 -0
- data/bin/update +33 -0
- data/bin/yarn +13 -0
- data/config/application.rb +8 -6
- data/config/boot.rb +1 -1
- data/config/brakeman.ignore +2 -2
- data/config/database.postgres.docker.yml +5 -5
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +1 -0
- data/config/environments/test.rb +7 -0
- data/config/initializers/action_mailer.rb +1 -3
- data/config/initializers/application_controller_renderer.rb +9 -0
- data/config/initializers/assets.rb +6 -11
- data/config/initializers/backtrace_silencers.rb +0 -6
- data/config/initializers/content_security_policy.rb +26 -0
- data/config/initializers/cookies_serializer.rb +3 -6
- data/config/initializers/devise.rb +289 -0
- data/config/initializers/filter_parameter_logging.rb +0 -5
- data/config/initializers/gravatar.rb +0 -1
- data/config/initializers/inflections.rb +0 -6
- data/config/initializers/mime_types.rb +1 -9
- data/config/initializers/new_framework_defaults_5_2.rb +40 -0
- data/config/initializers/relative_url_root.rb +1 -3
- data/config/initializers/session_store.rb +1 -3
- data/config/initializers/wrap_parameters.rb +4 -9
- data/config/locales/fat_free_crm.en-GB.yml +5 -5
- data/config/locales/fat_free_crm.en-US.yml +5 -5
- data/config/locales/fat_free_crm.fr.yml +1 -1
- data/config/locales/fat_free_crm.ru.yml +1 -0
- data/config/routes.rb +20 -9
- data/db/demo/users.yml +62 -81
- data/db/migrate/20100928030620_remove_uuid.rb +1 -2
- data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
- data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
- data/db/schema.rb +48 -43
- data/docker-compose.yml +10 -0
- data/fat_free_crm.gemspec +11 -13
- data/lib/development_tasks/license.rake +2 -2
- data/lib/fat_free_crm/callback.rb +2 -2
- data/lib/fat_free_crm/comment_extensions.rb +2 -4
- data/lib/fat_free_crm/core_ext/string.rb +1 -1
- data/lib/fat_free_crm/engine.rb +1 -1
- data/lib/fat_free_crm/errors.rb +1 -1
- data/lib/fat_free_crm/export_csv.rb +1 -0
- data/lib/fat_free_crm/exportable.rb +1 -1
- data/lib/fat_free_crm/fields.rb +1 -1
- data/lib/fat_free_crm/gem_dependencies.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -3
- data/lib/fat_free_crm/i18n.rb +2 -2
- data/lib/fat_free_crm/mail_processor/base.rb +4 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
- data/lib/fat_free_crm/permissions.rb +7 -4
- data/lib/fat_free_crm/sortable.rb +1 -1
- data/lib/fat_free_crm/tabs.rb +2 -2
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/gravatar_image_tag.rb +7 -8
- data/lib/missing_translation_detector.rb +1 -0
- data/lib/tasks/ffcrm/missing_translations.rake +1 -0
- data/lib/tasks/ffcrm/setup.rake +10 -1
- data/lib/tasks/ffcrm/update_data.rake +2 -2
- data/script/rails +2 -2
- data/spec/controllers/admin/users_controller_spec.rb +0 -56
- data/spec/controllers/comments_controller_spec.rb +6 -6
- data/spec/controllers/entities/campaigns_controller_spec.rb +1 -1
- data/spec/controllers/entities/contacts_controller_spec.rb +2 -1
- data/spec/controllers/entities/leads_controller_spec.rb +2 -2
- data/spec/controllers/entities/opportunities_controller_spec.rb +1 -1
- data/spec/controllers/entities_controller_spec.rb +5 -0
- data/spec/controllers/home_controller_spec.rb +5 -5
- data/spec/controllers/tasks_controller_spec.rb +6 -4
- data/spec/controllers/users_controller_spec.rb +28 -98
- data/spec/factories/account_factories.rb +5 -5
- data/spec/factories/campaign_factories.rb +3 -3
- data/spec/factories/contact_factories.rb +8 -8
- data/spec/factories/field_factories.rb +4 -3
- data/spec/factories/lead_factories.rb +5 -5
- data/spec/factories/list_factories.rb +2 -2
- data/spec/factories/opportunity_factories.rb +3 -3
- data/spec/factories/setting_factories.rb +2 -2
- data/spec/factories/shared_factories.rb +11 -9
- data/spec/factories/task_factories.rb +7 -7
- data/spec/factories/user_factories.rb +16 -19
- data/spec/features/admin/groups_spec.rb +1 -1
- data/spec/features/admin/users_spec.rb +3 -1
- data/spec/features/campaigns_spec.rb +1 -1
- data/spec/features/contacts_spec.rb +1 -1
- data/spec/features/dashboard_spec.rb +1 -1
- data/spec/features/devise/sign_in_spec.rb +58 -0
- data/spec/features/devise/sign_up_spec.rb +36 -0
- data/spec/features/leads_spec.rb +1 -1
- data/spec/features/opportunities_overview_spec.rb +1 -1
- data/spec/features/opportunities_spec.rb +3 -3
- data/spec/features/support/browser.rb +2 -1
- data/spec/features/tasks_spec.rb +1 -1
- data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
- data/spec/helpers/users_helper_spec.rb +4 -4
- data/spec/lib/comment_extensions_spec.rb +10 -4
- data/spec/lib/errors_spec.rb +2 -2
- data/spec/lib/mail_processor/dropbox_spec.rb +1 -1
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
- data/spec/lib/permissions_spec.rb +8 -3
- data/spec/mailers/devise_mailer_spec.rb +35 -0
- data/spec/mailers/user_mailer_spec.rb +0 -26
- data/spec/models/entities/account_spec.rb +27 -0
- data/spec/models/entities/contact_spec.rb +96 -1
- data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
- data/spec/models/fields/custom_field_spec.rb +4 -2
- data/spec/models/observers/entity_observer_spec.rb +1 -1
- data/spec/models/polymorphic/version_spec.rb +7 -7
- data/spec/models/users/user_spec.rb +22 -26
- data/spec/routing/users_routing_spec.rb +30 -8
- data/spec/shared/controllers.rb +3 -9
- data/spec/spec_helper.rb +10 -2
- data/spec/support/assert_select.rb +1 -0
- data/spec/support/devise_helpers.rb +28 -0
- data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +10 -10
- data/spec/support/macros.rb +4 -1
- data/spec/views/contacts/update.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/update.js.haml_spec.rb +1 -1
- data/vendor/gems/ransack_ui-1.3.4/.gitignore +17 -0
- data/vendor/gems/ransack_ui-1.3.4/Gemfile +7 -0
- data/vendor/gems/ransack_ui-1.3.4/LICENSE.txt +22 -0
- data/vendor/gems/ransack_ui-1.3.4/README.md +57 -0
- data/vendor/gems/ransack_ui-1.3.4/Rakefile +1 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/calendar.png +0 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/delete.png +0 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack/predicates.js.coffee +41 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee +26 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/index.js.coffee +2 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/index.js +2 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb +499 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/index.css +3 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/search.css.scss +41 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_condition_fields.html.erb +15 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_grouping_fields.html.erb +16 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_search.html.erb +29 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_sort_fields.html.erb +4 -0
- data/vendor/gems/ransack_ui-1.3.4/config/locales/en.yml +24 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui.rb +9 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record.rb +6 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record/base.rb +46 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/controller_helpers.rb +18 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/rails/engine.rb +21 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/adapters/active_record/base.rb +47 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/configuration.rb +15 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/context.rb +9 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/helpers/form_builder.rb +262 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/attribute.rb +13 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/condition.rb +13 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/grouping.rb +20 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/version.rb +3 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/view_helpers.rb +30 -0
- data/vendor/gems/ransack_ui-1.3.4/ransack_ui.gemspec +23 -0
- metadata +79 -67
- data/app/controllers/authentications_controller.rb +0 -53
- data/app/models/users/authentication.rb +0 -56
- data/app/views/authentications/new.html.haml +0 -19
- data/app/views/passwords/edit.html.haml +0 -15
- data/app/views/passwords/new.html.haml +0 -10
- data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
- data/app/views/users/new.html.haml +0 -19
- data/spec/controllers/authentications_controller_spec.rb +0 -150
- data/spec/controllers/passwords_controller_spec.rb +0 -32
- data/spec/models/users/authentication_spec.rb +0 -19
- data/spec/support/auth_macros.rb +0 -49
- data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
class AuthenticationsController < ApplicationController
|
9
|
-
before_action :require_no_user, only: %i[new create show]
|
10
|
-
before_action :require_user, only: :destroy
|
11
|
-
|
12
|
-
#----------------------------------------------------------------------------
|
13
|
-
def new
|
14
|
-
@authentication = Authentication.new
|
15
|
-
end
|
16
|
-
|
17
|
-
#----------------------------------------------------------------------------
|
18
|
-
def show
|
19
|
-
redirect_to login_url
|
20
|
-
end
|
21
|
-
|
22
|
-
#----------------------------------------------------------------------------
|
23
|
-
def create
|
24
|
-
@authentication = Authentication.new(params[:authentication].permit(:username, :password, :remember_me).to_h)
|
25
|
-
|
26
|
-
if @authentication.save && !@authentication.user.suspended?
|
27
|
-
flash[:notice] = t(:msg_welcome)
|
28
|
-
if @authentication.user.login_count > 1 && @authentication.user.last_login_at?
|
29
|
-
flash[:notice] += " " + t(:msg_last_login, l(@authentication.user.last_login_at, format: :mmddhhss))
|
30
|
-
end
|
31
|
-
redirect_back_or_default root_url
|
32
|
-
else
|
33
|
-
if @authentication.user&.awaits_approval?
|
34
|
-
flash[:notice] = t(:msg_account_not_approved)
|
35
|
-
else
|
36
|
-
flash[:warning] = t(:msg_invalig_login)
|
37
|
-
end
|
38
|
-
redirect_to action: :new
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# The login form gets submitted to :update action when @authentication is
|
43
|
-
# saved (@authentication != nil) but the user is suspended.
|
44
|
-
#----------------------------------------------------------------------------
|
45
|
-
alias update create
|
46
|
-
|
47
|
-
#----------------------------------------------------------------------------
|
48
|
-
def destroy
|
49
|
-
current_user_session.destroy
|
50
|
-
flash[:notice] = t(:msg_goodbye)
|
51
|
-
redirect_back_or_default login_url
|
52
|
-
end
|
53
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
class Authentication < Authlogic::Session::Base # NOTE: This is not ActiveRecord model.
|
9
|
-
authenticate_with User
|
10
|
-
after_save :check_if_suspended
|
11
|
-
single_access_allowed_request_types :any
|
12
|
-
|
13
|
-
def to_key
|
14
|
-
id ? id : nil
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
# Override Authlogic's validate_by_password() to allow blank passwords. See
|
20
|
-
# authlogic/lib/authlogic/session/password.rb for details.
|
21
|
-
#----------------------------------------------------------------------------
|
22
|
-
def validate_by_password
|
23
|
-
self.invalid_password = false
|
24
|
-
|
25
|
-
self.attempted_record = search_for_record(find_by_login_method, send(login_field))
|
26
|
-
if attempted_record.blank?
|
27
|
-
generalize_credentials_error_messages? ?
|
28
|
-
add_general_credentials_error :
|
29
|
-
errors.add(login_field, I18n.t('error_messages.login_not_found', default: "is not valid"))
|
30
|
-
return
|
31
|
-
end
|
32
|
-
|
33
|
-
unless attempted_record.send(verify_password_method, send("protected_#{password_field}"))
|
34
|
-
self.invalid_password = true
|
35
|
-
generalize_credentials_error_messages? ?
|
36
|
-
add_general_credentials_error :
|
37
|
-
errors.add(password_field, I18n.t('error_messages.password_invalid', default: "is not valid"))
|
38
|
-
return
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Override Authologic instance method in order to keep :login_count,
|
43
|
-
# :last_login_at, and :last_login_ip intact if the user is suspended.
|
44
|
-
# See vendor/plugin/authlogin/lib/authlogic/session/magic_columns.rb.
|
45
|
-
#----------------------------------------------------------------------------
|
46
|
-
def update_info
|
47
|
-
super unless user.suspended?
|
48
|
-
end
|
49
|
-
|
50
|
-
#----------------------------------------------------------------------------
|
51
|
-
def check_if_suspended
|
52
|
-
errors.add(:base, I18n.t(:msg_account_suspended)) if user.suspended?
|
53
|
-
end
|
54
|
-
|
55
|
-
ActiveSupport.run_load_hooks(:fat_free_crm_authentication, self)
|
56
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
.standalone#standalone
|
2
|
-
-# The following form gets submitted to #create when @authentication is nil,
|
3
|
-
-# or to #update when @authentication is not nil (ex. suspended).
|
4
|
-
= form_for @authentication, url: authentication_path, html: one_submit_only do |f|
|
5
|
-
- if can_signup?
|
6
|
-
.title_tools #{t :no_account} #{link_to t(:sign_up_now), signup_path}
|
7
|
-
.title= t(:login)
|
8
|
-
.section
|
9
|
-
.label= t(:username) + ':'
|
10
|
-
= f.text_field :username
|
11
|
-
.label= t(:password) + ':'
|
12
|
-
= f.password_field :password
|
13
|
-
|
14
|
-
%div(style="margin-left:12px") #{f.check_box(:remember_me)} #{t :remember_me}
|
15
|
-
%br
|
16
|
-
.buttonbar
|
17
|
-
= f.submit t(:login)
|
18
|
-
#{t :or}
|
19
|
-
= link_to t(:forgot_password) << '?', new_password_path
|
@@ -1,15 +0,0 @@
|
|
1
|
-
.standalone
|
2
|
-
= form_for(@user, url: password_path(params[:id]), html: one_submit_only, method: :put) do |f|
|
3
|
-
.title #{t :reset_password}
|
4
|
-
|
5
|
-
= f.error_messages object_name: t('password')
|
6
|
-
|
7
|
-
.intro #{t :confirm_password_intro}
|
8
|
-
.section
|
9
|
-
.label #{t :new_password}:
|
10
|
-
= f.password_field :password
|
11
|
-
.label #{t :password_confirmation}:
|
12
|
-
= f.password_field :password_confirmation
|
13
|
-
%br
|
14
|
-
.buttonbar
|
15
|
-
= f.submit t(:update_password_and_login)
|
@@ -1,6 +0,0 @@
|
|
1
|
-
:plain
|
2
|
-
A request to reset your password has been made. If you did not make this request, simply ignore this email. If you did make this request just click the link below:
|
3
|
-
|
4
|
-
#{@edit_password_url}
|
5
|
-
|
6
|
-
If the above URL does not work try copying and pasting it into your browser. If you continue to have problem please feel free to contact us.
|
@@ -1,19 +0,0 @@
|
|
1
|
-
.standalone
|
2
|
-
= form_for(@user, html: one_submit_only) do |f|
|
3
|
-
.title_tools #{t :already_signed_up} #{link_to t(:login_now_link), login_path}
|
4
|
-
.title #{t :sign_up}
|
5
|
-
|
6
|
-
= f.error_messages object_name: t('user')
|
7
|
-
|
8
|
-
.section
|
9
|
-
.label #{t :email}:
|
10
|
-
= f.text_field :email
|
11
|
-
.label #{t :username}:
|
12
|
-
= f.text_field :username
|
13
|
-
.label #{t :password}:
|
14
|
-
= f.password_field :password
|
15
|
-
.label #{t :password_confirmation}:
|
16
|
-
= f.password_field :password_confirmation
|
17
|
-
|
18
|
-
.buttonbar
|
19
|
-
= f.submit t(:sign_up_button)
|
@@ -1,150 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
9
|
-
|
10
|
-
describe AuthenticationsController do
|
11
|
-
before(:each) do
|
12
|
-
activate_authlogic
|
13
|
-
logout
|
14
|
-
end
|
15
|
-
|
16
|
-
# Authentication filters
|
17
|
-
#----------------------------------------------------------------------------
|
18
|
-
describe "authentication filters" do
|
19
|
-
describe "user must not be logged" do
|
20
|
-
describe "DELETE authentication (logout form)" do
|
21
|
-
it "displays 'must be logged out message' and redirects to login page" do
|
22
|
-
delete :destroy
|
23
|
-
expect(flash[:notice]).not_to eq(nil)
|
24
|
-
expect(flash[:notice]).to match(/^You must be logged in/)
|
25
|
-
expect(response).to redirect_to(login_path)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "redirects to login page" do
|
29
|
-
get :show
|
30
|
-
expect(response).to redirect_to(login_path)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "user must not be logged in" do
|
36
|
-
before(:each) do
|
37
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass")
|
38
|
-
allow(@controller).to receive(:current_user).and_return(@user)
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "GET authentication (login form)" do
|
42
|
-
it "displays 'must be logged out message' and redirects to profile page" do
|
43
|
-
get :new
|
44
|
-
expect(flash[:notice]).not_to eq(nil)
|
45
|
-
expect(flash[:notice]).to match(/^You must be logged out/)
|
46
|
-
expect(response).to redirect_to(profile_path)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "POST authentication" do
|
51
|
-
it "displays 'must be logged out message' and redirects to profile page" do
|
52
|
-
post :create, params: { authentication: @login }
|
53
|
-
expect(flash[:notice]).not_to eq(nil)
|
54
|
-
expect(flash[:notice]).to match(/^You must be logged out/)
|
55
|
-
expect(response).to redirect_to(profile_path)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# POST /authentications
|
62
|
-
# POST /authentications.xml HTML
|
63
|
-
#----------------------------------------------------------------------------
|
64
|
-
describe "POST authentications" do
|
65
|
-
before(:each) do
|
66
|
-
@login = { username: "user", password: "pass", remember_me: "0" }
|
67
|
-
@authentication = double(Authentication, @login)
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "successful authentication " do
|
71
|
-
before(:each) do
|
72
|
-
allow(@authentication).to receive(:save).and_return(true)
|
73
|
-
allow(Authentication).to receive(:new).and_return(@authentication)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "displays welcome message and redirects to the home page" do
|
77
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass", login_count: 0)
|
78
|
-
allow(@authentication).to receive(:user).and_return(@user)
|
79
|
-
|
80
|
-
post :create, params: { authentication: @login }
|
81
|
-
expect(flash[:notice]).not_to eq(nil)
|
82
|
-
expect(flash[:notice]).not_to match(/last login/)
|
83
|
-
expect(response).to redirect_to(root_path)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "displays last login time if it's not the first login" do
|
87
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass", login_count: 42)
|
88
|
-
allow(@authentication).to receive(:user).and_return(@user)
|
89
|
-
|
90
|
-
post :create, params: { authentication: @login }
|
91
|
-
expect(flash[:notice]).to match(/last login/)
|
92
|
-
expect(response).to redirect_to(root_path)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "authenticaion failure" do
|
97
|
-
describe "user is not suspended" do
|
98
|
-
it "redirects to login page if username or password are invalid" do
|
99
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass")
|
100
|
-
allow(@authentication).to receive(:user).and_return(@user)
|
101
|
-
allow(@authentication).to receive(:save).and_return(false) # <--- Authentication failure.
|
102
|
-
allow(Authentication).to receive(:new).and_return(@authentication)
|
103
|
-
|
104
|
-
post :create, params: { authentication: @login }
|
105
|
-
expect(flash[:warning]).not_to eq(nil)
|
106
|
-
expect(response).to redirect_to(action: :new)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "user has been suspended" do
|
111
|
-
before(:each) do
|
112
|
-
allow(@authentication).to receive(:save).and_return(true)
|
113
|
-
allow(Authentication).to receive(:new).and_return(@authentication)
|
114
|
-
end
|
115
|
-
|
116
|
-
# This tests :before_save update_info callback in Authentication model.
|
117
|
-
it "keeps user login attributes intact" do
|
118
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass", suspended_at: Date.yesterday, login_count: 0, last_login_at: nil, last_login_ip: nil)
|
119
|
-
allow(@authentication).to receive(:user).and_return(@user)
|
120
|
-
|
121
|
-
post :create, params: { authentication: @login }
|
122
|
-
expect(@authentication.user.login_count).to eq(0)
|
123
|
-
expect(@authentication.user.last_login_at).to be_nil
|
124
|
-
expect(@authentication.user.last_login_ip).to be_nil
|
125
|
-
end
|
126
|
-
|
127
|
-
it "redirects to login page if user is suspended" do
|
128
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass", suspended_at: Date.yesterday)
|
129
|
-
allow(@authentication).to receive(:user).and_return(@user)
|
130
|
-
|
131
|
-
post :create, params: { authentication: @login }
|
132
|
-
expect(flash[:warning]).not_to eq(nil) # Invalid username/password.
|
133
|
-
expect(flash[:notice]).to eq(nil) # Not approved yet.
|
134
|
-
expect(response).to redirect_to(action: :new)
|
135
|
-
end
|
136
|
-
|
137
|
-
it "redirects to login page with the message if signup needs approval and user hasn't been activated yet" do
|
138
|
-
allow(Setting).to receive(:user_signup).and_return(:needs_approval)
|
139
|
-
@user = create(:user, username: "user", password: "pass", password_confirmation: "pass", suspended_at: Date.yesterday, login_count: 0)
|
140
|
-
allow(@authentication).to receive(:user).and_return(@user)
|
141
|
-
|
142
|
-
post :create, params: { authentication: @login }
|
143
|
-
expect(flash[:warning]).to eq(nil) # Invalid username/password.
|
144
|
-
expect(flash[:notice]).not_to eq(nil) # Not approved yet.
|
145
|
-
expect(response).to redirect_to(action: :new)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require 'spec_helper'
|
9
|
-
|
10
|
-
describe PasswordsController do
|
11
|
-
let(:user) { build(:user) }
|
12
|
-
|
13
|
-
describe "update" do
|
14
|
-
before(:each) do
|
15
|
-
allow(User).to receive(:find_using_perishable_token).and_return(user)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should accept non-blank passwords" do
|
19
|
-
password = "password"
|
20
|
-
expect(user).to receive(:update_attributes).and_return(true)
|
21
|
-
put :update, params: { id: 1, user: { password: password, password_confirmation: password } }
|
22
|
-
expect(response).to redirect_to(profile_url)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should not accept blank passwords" do
|
26
|
-
password = " "
|
27
|
-
expect(user).not_to receive(:update_attributes)
|
28
|
-
put :update, params: { id: 1, user: { password: password, password_confirmation: password } }
|
29
|
-
expect(response).to render_template('edit')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
9
|
-
|
10
|
-
describe Authentication do
|
11
|
-
before(:each) do
|
12
|
-
@valid_attributes = {
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
# it "should create a new instance given valid attributes" do
|
17
|
-
# Authentication.create!(@valid_attributes)
|
18
|
-
# end
|
19
|
-
end
|
data/spec/support/auth_macros.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
# See vendor/plugins/authlogic/lib/authlogic/test_case.rb
|
9
|
-
#----------------------------------------------------------------------------
|
10
|
-
def activate_authlogic
|
11
|
-
require 'authlogic/test_case/rails_request_adapter'
|
12
|
-
require 'authlogic/test_case/mock_cookie_jar'
|
13
|
-
require 'authlogic/test_case/mock_request'
|
14
|
-
|
15
|
-
Authlogic::Session::Base.controller = (@request && Authlogic::TestCase::RailsRequestAdapter.new(@request)) || controller
|
16
|
-
end
|
17
|
-
|
18
|
-
# Note: Authentication is NOT ActiveRecord model, so we mock and stub it using RSpec.
|
19
|
-
#----------------------------------------------------------------------------
|
20
|
-
def login(user_stubs = {}, session_stubs = {})
|
21
|
-
User.current_user = @current_user = create(:user, user_stubs)
|
22
|
-
@current_user_session = double(Authentication, { record: current_user }.merge(session_stubs))
|
23
|
-
allow(Authentication).to receive(:find).and_return(@current_user_session)
|
24
|
-
# set_timezone
|
25
|
-
assigns[:current_user] = current_user
|
26
|
-
end
|
27
|
-
|
28
|
-
#----------------------------------------------------------------------------
|
29
|
-
def login_admin
|
30
|
-
login(admin: true)
|
31
|
-
end
|
32
|
-
|
33
|
-
#----------------------------------------------------------------------------
|
34
|
-
def logout
|
35
|
-
@current_user = nil
|
36
|
-
@current_user_session = nil
|
37
|
-
allow(Authentication).to receive(:find).and_return(nil)
|
38
|
-
end
|
39
|
-
alias require_no_user logout
|
40
|
-
|
41
|
-
#----------------------------------------------------------------------------
|
42
|
-
def current_user
|
43
|
-
@current_user
|
44
|
-
end
|
45
|
-
|
46
|
-
#----------------------------------------------------------------------------
|
47
|
-
def current_user_session
|
48
|
-
@current_user_session
|
49
|
-
end
|