diff --git a/.ruby-version b/.ruby-version index 24ba9a3..57cf282 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.0 +2.6.5 diff --git a/Gemfile b/Gemfile index 2f31176..645f967 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.7.0' +ruby '2.6.5' gem 'pg' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' @@ -60,8 +60,8 @@ gem 'bootstrap4-kaminari-views' gem 'devise' gem 'devise_invitable' #, '~> 2.0.0' -gem 'omniauth-facebook' # use very carefuylly -gem 'omniauth-twitter' +# gem 'omniauth-facebook' # use very carefuylly +# gem 'omniauth-twitter' # gem 'omniauth-linkedin' gem 'kaminari' diff --git a/Gemfile.lock b/Gemfile.lock index 595b0f0..60f34ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,14 +60,14 @@ GEM public_suffix (>= 2.0.2, < 5.0) bcrypt (3.1.13) bindex (0.8.1) - bootsnap (1.4.5) + bootsnap (1.4.6) msgpack (~> 1.0) bootstrap4-kaminari-views (1.0.1) kaminari (>= 0.13) rails (>= 3.1) builder (3.2.4) - byebug (11.0.1) - capybara (3.30.0) + byebug (11.1.1) + capybara (3.31.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -79,8 +79,8 @@ GEM capybara (>= 2.4, < 4.0) mail childprocess (3.0.0) - concurrent-ruby (1.1.5) - crass (1.0.5) + concurrent-ruby (1.1.6) + crass (1.0.6) devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -91,30 +91,26 @@ GEM actionmailer (>= 5.0) devise (>= 4.6) erubi (1.9.0) - faraday (1.0.0) - multipart-post (>= 1.2, < 3) - ffi (1.11.3) + ffi (1.12.2) globalid (0.4.2) activesupport (>= 4.2.0) - hashie (3.6.0) - i18n (1.7.0) + i18n (1.8.2) concurrent-ruby (~> 1.0) - jbuilder (2.9.1) - activesupport (>= 4.2.0) + jbuilder (2.10.0) + activesupport (>= 5.0.0) json (2.3.0) - jwt (2.2.1) - kaminari (1.1.1) + kaminari (1.2.0) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.0) + kaminari-activerecord (= 1.2.0) + kaminari-core (= 1.2.0) + kaminari-actionview (1.2.0) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.0) + kaminari-activerecord (1.2.0) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) + kaminari-core (= 1.2.0) + kaminari-core (1.2.0) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -127,46 +123,22 @@ GEM marcel (0.3.3) mimemagic (~> 0.3.2) method_source (0.9.2) - mimemagic (0.3.3) + mimemagic (0.3.4) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.13.0) - msgpack (1.3.1) - multi_json (1.14.1) - multi_xml (0.6.0) - multipart-post (2.1.1) + minitest (5.14.0) + msgpack (1.3.3) nio4r (2.5.2) - nokogiri (1.10.7) + nokogiri (1.10.8) mini_portile2 (~> 2.4.0) - oauth (0.5.4) - oauth2 (1.4.2) - faraday (>= 0.8, < 2.0) - jwt (>= 1.0, < 3.0) - multi_json (~> 1.3) - multi_xml (~> 0.5) - rack (>= 1.2, < 3) - omniauth (1.9.0) - hashie (>= 3.4.6, < 3.7.0) - rack (>= 1.6.2, < 3) - omniauth-facebook (5.0.0) - omniauth-oauth2 (~> 1.2) - omniauth-oauth (1.1.0) - oauth - omniauth (~> 1.0) - omniauth-oauth2 (1.6.0) - oauth2 (~> 1.1) - omniauth (~> 1.9) - omniauth-twitter (1.4.0) - omniauth-oauth (~> 1.1) - rack orm_adapter (0.5.0) paranoia (2.4.2) activerecord (>= 4.0, < 6.1) - pg (1.2.1) + pg (1.2.2) public_suffix (4.0.3) puma (4.3.1) nio4r (~> 2.0) - rack (2.0.8) + rack (2.2.2) rack-proxy (0.6.5) rack rack-test (1.1.0) @@ -201,14 +173,14 @@ GEM rb-fsevent (0.10.3) rb-inotify (0.10.1) ffi (~> 1.0) - recaptcha (5.2.1) + recaptcha (5.3.0) json - regexp_parser (1.6.0) + regexp_parser (1.7.0) responders (3.0.0) actionpack (>= 5.0) railties (>= 5.0) ruby_dep (1.5.0) - rubyzip (2.0.0) + rubyzip (2.2.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) sassc (2.2.1) @@ -222,14 +194,14 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - simple_form (5.0.1) + simple_form (5.0.2) actionpack (>= 5.0) activemodel (>= 5.0) spring (2.1.0) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (3.7.2) + sprockets (4.0.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) @@ -280,8 +252,6 @@ DEPENDENCIES jbuilder (~> 2.7) kaminari listen (>= 3.0.5, < 3.2) - omniauth-facebook - omniauth-twitter paranoia (~> 2.2) pg puma (~> 4.1) @@ -298,7 +268,7 @@ DEPENDENCIES webpacker (~> 4.0) RUBY VERSION - ruby 2.7.0p0 + ruby 2.6.5p114 BUNDLED WITH 2.1.4 diff --git a/app/models/user.rb b/app/models/user.rb index 25e5479..dce09cd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,22 +8,22 @@ class User < ApplicationRecord belongs_to :account has_and_belongs_to_many :roles - has_many :identities, :dependent => :destroy + has_many :identities, dependent: :destroy # has_many :wallets - validates_format_of :email, :without => TEMP_EMAIL_REGEX, on: :update + validates_format_of :email, without: TEMP_EMAIL_REGEX, on: :update paginates_per 10 devise :invitable, :database_authenticatable, :registerable, :confirmable, - :lockable, :recoverable, :rememberable, :trackable, :validatable, - :omniauthable, :omniauth_providers => [:facebook, :twitter] + :lockable, :recoverable, :rememberable, :trackable, :validatable + #,:omniauthable, :omniauth_providers => [:facebook, :twitter] # before_invitation_created :setup_role # before_invitation_created :setup_account #:facebook, :twitter, :linkedin] def role? role - return !!self.roles.find_by_name(role.to_s) + !!roles.find_by_name(role.to_s) end def self.find_for_oauth(auth, signed_in_resource = nil) @@ -34,25 +34,24 @@ def self.find_for_oauth(auth, signed_in_resource = nil) # что бы identity не была закрыта случайно созданным аккаунтом. # Заметьте, что это может оставить зомби-аккаунты (без прикрепленной identity) # которые позже могут быть удалены - user = signed_in_resource ? signed_in_resource : identity.user + user = signed_in_resource || identity.user # Создать пользователя, если нужно if user.nil? - # Получить email пользователя, если его предоставляет провайдер # Если email не был предоставлен мы даем пользователю временный и просим # пользователя установить и подтвердить новый в следующим шаге через UsersController.finish_signup # email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email) # email = auth.info.email if email_is_verified email = auth.info.email if auth.info.email - user = User.where(:email => email).first if email + user = User.where(email: email).first if email # Создать пользователя, если это новая запись if user.nil? user = User.new( - name: auth.extra.raw_info.name, - email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com", - password: Devise.friendly_token[0, 20] + name: auth.extra.raw_info.name, + email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com", + password: Devise.friendly_token[0, 20] ) user.skip_confirmation! user.save! @@ -68,7 +67,7 @@ def self.find_for_oauth(auth, signed_in_resource = nil) end def email_verified? - self.email && self.email !~ TEMP_EMAIL_REGEX + email && email !~ TEMP_EMAIL_REGEX end #Protected methods do not invoke in devise_invitable @@ -76,14 +75,14 @@ def email_verified? protected def setup_role - self.role_ids = [3] if self.invited_by_id != nil && self.role_ids.empty? - self.role_ids = [2] if self.role_ids.empty? + self.role_ids = [3] if !invited_by_id.nil? && role_ids.empty? + self.role_ids = [2] if role_ids.empty? end # Default role is "Registered" def setup_account - self.account = self.invited_by.account if self.invited_by_id != nil && self.account_id == nil - self.account = Account.create if self.account_id == nil + self.account = invited_by.account if !invited_by_id.nil? && account_id.nil? + self.account = Account.create if account_id.nil? end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e3726ce..35c7c1b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -48,12 +48,11 @@ <%= link_to t('shared.labels.logout'), destroy_user_session_path, :method => :delete, :class => 'nav-link' %> <% else %> -