Commit f8b7ff2c by Mykhailo Makohin

some changes with user autentification

parent da22df9e
...@@ -18,7 +18,7 @@ gem 'devise' ...@@ -18,7 +18,7 @@ gem 'devise'
gem 'omniauth' gem 'omniauth'
gem 'omniauth-facebook' gem 'omniauth-facebook'
gem 'omniauth-google-oauth2' gem 'omniauth-google-oauth2'
gem 'omniauth-linkedin-oauth2' gem 'omniauth-twitter'
gem 'haml' gem 'haml'
gem 'bootstrap-sass' gem 'bootstrap-sass'
gem 'gmaps4rails' gem 'gmaps4rails'
......
...@@ -103,6 +103,7 @@ GEM ...@@ -103,6 +103,7 @@ GEM
nio4r (2.5.0) nio4r (2.5.0)
nokogiri (1.10.4) nokogiri (1.10.4)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
oauth (0.5.4)
oauth2 (1.4.1) oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0) faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0) jwt (>= 1.0, < 3.0)
...@@ -120,9 +121,15 @@ GEM ...@@ -120,9 +121,15 @@ GEM
omniauth-oauth2 (>= 1.6) omniauth-oauth2 (>= 1.6)
omniauth-linkedin-oauth2 (1.0.0) omniauth-linkedin-oauth2 (1.0.0)
omniauth-oauth2 omniauth-oauth2
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.6.0) omniauth-oauth2 (1.6.0)
oauth2 (~> 1.1) oauth2 (~> 1.1)
omniauth (~> 1.9) omniauth (~> 1.9)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
orm_adapter (0.5.0) orm_adapter (0.5.0)
puma (3.12.1) puma (3.12.1)
rack (2.0.7) rack (2.0.7)
...@@ -227,6 +234,7 @@ DEPENDENCIES ...@@ -227,6 +234,7 @@ DEPENDENCIES
omniauth-facebook omniauth-facebook
omniauth-google-oauth2 omniauth-google-oauth2
omniauth-linkedin-oauth2 omniauth-linkedin-oauth2
omniauth-twitter
puma (~> 3.0) puma (~> 3.0)
rails (~> 5.0.7, >= 5.0.7.2) rails (~> 5.0.7, >= 5.0.7.2)
remotipart remotipart
......
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options
{ locale: I18n.locale }
end
end end
...@@ -5,12 +5,12 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -5,12 +5,12 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
sign_in_with "Facebook" sign_in_with "Facebook"
end end
def failure def twitter
redirect_to root_path sign_in_with "Twitter"
end end
def linkedin def failure
sign_in_with "LinkedIn" redirect_to root_path
end end
def google_oauth2 def google_oauth2
......
...@@ -16,8 +16,8 @@ class UsersController < ApplicationController ...@@ -16,8 +16,8 @@ class UsersController < ApplicationController
@user = User.find_or_create_by(user_params) @user = User.find_or_create_by(user_params)
@user.skip_password_validation = true @user.skip_password_validation = true
if @user.save if @user.save
redirect_to root_path redirect_to edit_user_path(@user)
else elsif
redirect_to root_path redirect_to root_path
end end
end end
...@@ -28,9 +28,12 @@ class UsersController < ApplicationController ...@@ -28,9 +28,12 @@ class UsersController < ApplicationController
def update def update
@user = resource @user = resource
@user.skip_password_validation = false
if @user.update(user_params) if @user.update(user_params)
redirect_to user_path(user: @user) sign_in @user
redirect_to user_path(@user)
else else
puts @user.errors.messages
render :edit render :edit
end end
end end
...@@ -53,7 +56,8 @@ class UsersController < ApplicationController ...@@ -53,7 +56,8 @@ class UsersController < ApplicationController
end end
def user_params def user_params
params.require(:user).permit(:email, :name, :location) params.require(:user).permit(:email, :name, :location,
:password, :password_confirmation)
end end
end end
\ No newline at end of file
class User < ApplicationRecord class User < ApplicationRecord
attr_accessor :skip_password_validation attr_accessor :skip_password_validation
validates :name, presence: true
devise :database_authenticatable, :registerable, devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable, :omniauthable, :recoverable, :rememberable, :validatable, :omniauthable,
omniauth_providers: [:facebook, :google_oauth2, :linkedin] omniauth_providers: [:facebook, :google_oauth2, :twitter]
def self.new_with_session(params, session) def self.new_with_session(params, session)
super.tap do |user| super.tap do |user|
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#1.tab-pane.tab-pane_people.active #1.tab-pane.tab-pane_people.active
.main_head_title .main_head_title
= image_tag ("logo_lg.png") = image_tag ("logo_lg.png")
%h1= t ("body.title") %h1 платформа тепле місто
.title_highlighted= t ("body.title_highlighted") .title_highlighted Простір міста формують його жителі
.tab-pane_content .tab-pane_content
.bot_btn .bot_btn
%a.btn.btn_main{"data-target" => "#modal", "data-toggle" => "modal"}= t ("body.btn_main") %a.btn.btn_main{"data-target" => "#modal", "data-toggle" => "modal"} підтримати
.head_couters.clearfix .head_couters.clearfix
.counter .counter
.counter_value .counter_value
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
.counter_digit .counter_digit
%span 0 %span 0
.counter_gradient_top .counter_gradient_top
.counter_text= t ("body.joined_people") .counter_text об'єднаних людей
.counter.counter_violet .counter.counter_violet
.counter_value .counter_value
.counter_digit .counter_digit
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
.counter_digit .counter_digit
%span 0 %span 0
.counter_gradient_top .counter_gradient_top
.counter_text= t ("body.colected_money") .counter_text зібрано коштів
.cubes_wrap .cubes_wrap
.cubes_inner_wrap .cubes_inner_wrap
#cube-wall.cube-wall #cube-wall.cube-wall
......
...@@ -13,21 +13,21 @@ ...@@ -13,21 +13,21 @@
#bs-example-navbar-collapse-1.collapse.navbar-collapse #bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav %ul.nav.navbar-nav
%li %li
%a{:href => "#"}= t ("header.platfform") %a{:href => "#"} про платформу
%li %li
%a{:href => "#"}= t ("header.grants") %a{:href => "#"} гранти
%li %li
%a{:href => "#"}= t ("header.projects") %a{:href => "#"} проекти
%li %li
%a{:href => "#"}= t ("header.partners") %a{:href => "#"} партнери
%li %li
%a{:href => "#"}= t ("header.digital") %a{:href => "#"} digital workshop
%li %li
%a{:href => "#"}= t ("header.about_us") %a{:href => "#"} про нас
%li %li
%a{:href => "#"}= t ("header.news") %a{:href => "#"} новини
%li %li
%a{:href => "#"}= t ("header.reports") %a{:href => "#"} звіти
%li %li
%a{:href => "#"} connectif %a{:href => "#"} connectif
%li %li
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
= link_to('Logout', destroy_user_session_path, method: :delete) = link_to('Logout', destroy_user_session_path, method: :delete)
%ul.nav.nav-tabs.nav_btns %ul.nav.nav-tabs.nav_btns
%li.active %li.active
%a{"data-toggle" => "tab", :href => "#1"}= t 'header.people' %a{"data-toggle" => "tab", :href => "#1"} Люди
%li %li
%a{"data-toggle" => "tab", :href => "#2"}= t 'header.businesses' %a{"data-toggle" => "tab", :href => "#2"} Бізнеси
.show_tip .show_tip
Ознайомтесь з дружніми бізнесами Ознайомтесь з дружніми бізнесами
які допомагають формувати які допомагають формувати
...@@ -48,6 +48,6 @@ ...@@ -48,6 +48,6 @@
%button.login_btn{"data-target" => "#modal3", "data-toggle" => "modal"} %button.login_btn{"data-target" => "#modal3", "data-toggle" => "modal"}
= image_tag ("login.png") = image_tag ("login.png")
.search_block .search_block
%input#search_field.search_field{placeholder: "#{t 'header.find_by_name'}", :type => "text"}/ %input#search_field.search_field{placeholder: "Пошук по імені...", :type => "text"}/
%button.search_btn %button.search_btn
%i.icon.icon_search %i.icon.icon_search
\ No newline at end of file
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
.modal-header_bot .modal-header_bot
%h3#modalLabel.modal-title Вхід %h3#modalLabel.modal-title Вхід
.help_text.absolute .help_text.absolute
%span.asterisk * %span.asterisk> *
Поля обов'язкові для заповнення Всі поля обов'язкові для заповнення
.modal-body .modal-body
.row .row
.col-sm-9.modal-body_login .col-sm-9.modal-body_login
...@@ -19,30 +19,28 @@ ...@@ -19,30 +19,28 @@
Авторизація Авторизація
.form-group .form-group
%label{:for => "id_3"} %label{:for => "id_3"}
%span.asterisk> *
E-mail E-mail
.field_wrap .field_wrap
= f.input :email, class: 'form-control', label: false = f.email_field :email, class: 'form-control'
.form-group .form-group
%label{:for => "id_2"} %label{:for => "id_2"}
%span.asterisk> *
Ім'я та прізвище Ім'я та прізвище
.field_wrap .field_wrap
= f.input :name, class: 'form-control', label: false = f.input_field :name, class: 'form-control'
.form-group .form-group
%label{:for => "user_location"} %label{:for => "id_4"}
Населений пункт Населений пункт
.field_wrap .field_wrap
= f.input :location, class: 'form-control', label: "" %input#id_4.form-control{:type => "text"}/
.col-sm-3.modal-body_registration .col-sm-3.modal-body_registration
%h4.modal_subtitle %h4.modal_subtitle
Швидка реєстрація Швидка реєстрація
.soc_btn_wrap.clearfix .soc_btn_wrap.clearfix
%a.soc_btn.soc_btn_fb{href: "/users/auth/facebook"} %a.soc_btn.soc_btn_fb{:href => "/users/auth/facebook"}
%i.icon.icon_fb %i.icon.icon_fb
%a.soc_btn.soc_btn_tw{href: "/users/auth/linkedin"} %a.soc_btn.soc_btn_tw{:href => "/users/auth/twitter"}
%i.icon.icon_tw %i.icon.icon_tw
%a.soc_btn.soc_btn_google{href: "/users/auth/google_oauth2"} %a.soc_btn.soc_btn_google{:href => "/users/auth/google_oauth2"}
%i.icon.icon_google %i.icon.icon_google
.text-center .text-center
= f.button :submit, "Register Now", class: "btn btn-success btn-lg" = f.button :submit, "Вхід", class: "btn btn-success btn-lg"
...@@ -14,21 +14,21 @@ ...@@ -14,21 +14,21 @@
#bs-example-navbar-collapse-1.collapse.navbar-collapse #bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav %ul.nav.navbar-nav
%li %li
%a{:href => "#"}= t ("header.platfform") %a{:href => "#"} про платформу
%li %li
%a{:href => "#"}= t ("header.grants") %a{:href => "#"} гранти
%li %li
%a{:href => "#"}= t ("header.projects") %a{:href => "#"} проекти
%li %li
%a{:href => "#"}= t ("header.partners") %a{:href => "#"} партнери
%li %li
%a{:href => "#"}= t ("header.digital") %a{:href => "#"} digital workshop
%li %li
%a{:href => "#"}= t ("header.about_us") %a{:href => "#"} про нас
%li %li
%a{:href => "#"}= t ("header.news") %a{:href => "#"} новини
%li %li
%a{:href => "#"}= t ("header.reports") %a{:href => "#"} звіти
%li %li
%a{:href => "#"} connectif %a{:href => "#"} connectif
%li %li
......
= simple_form_for @user, url: user_path, html: { method: :put } do |f|
= f.error_notification
.wrapper
.content
.img_line
.container
.centered_form
.pseudo_btns
%span.btn.btn_faked реєстрація
.help_text
%span.asterisk *
Поля обов'язкові для заповнення
.form_container
.horizontal_input_group
.form-group
%label{:for => "id_1"}
%span.asterisk> *
Як вас звати?
.field_wrap
= f.input_field :name, class: 'form-control'
.form-group
%label{:for => "id_2"} Nickname
.field_wrap
%input#id_2.form-control{:type => "text", :value => "V@renyk"}/
.form-group
%label{:for => "id_3"}
%span.asterisk> *
E-mail
.field_wrap
= f.input_field :email, class: 'form-control'
.form-group
%label{:for => "id_4"} Facebook
.field_wrap
%input#id_4.form-control{:type => "text", :value => "https://www.facebook.com/liubko.deresh"}/
.form-group
%label{:for => "id_5"}
Місто
.field_wrap
= f.input_field :location, class: 'form-control'
.form-group
%label{:for => "id_5"}
%span.asterisk> *
Пароль
.field_wrap
= f.password_field :password, class: 'form-control'
.form-group
%label{:for => "id_5"}
%span.asterisk> *
Підтвердження паролю
.field_wrap
= f.password_field :password_confirmation, class: 'form-control'
.form-group
%label{:for => "id_5"}
Фото або лого
.field_wrap.upload_wrap
.upload_bot.clearfix
= file_field :avatar, class: 'form-control'
.upload_img
= image_tag url_for(user.avatar) if @user.avatar
.text-center
= f.submit "Оновити", class: 'btn btn-success btn-lg'
.wrapper
.content
.img_line
.container
.centered_form
.pseudo_btns
%span.btn.btn_faked Профіль користувача
.form_container
.form-group
%label{:for => "id_1"} Ім'я та прізвище
.field_wrap
#{@user.name}
.form-group
%label{:for => "id_2"} Nickname
.field_wrap
.form-group
%label{:for => "id_3"} E-mail
.field_wrap
#{@user.email}
.form-group
%label{:for => "id_4"} Профіль соц. мережі
.field_wrap
https://plus.google.com/103689649494006504923
.form-group
%label{:for => "id_5"} Місто
.field_wrap
#{@user.location}
.form-group
%label{:for => "id_5"} Фото або лого
.field_wrap.upload_wrap
.upload_bot.clearfix
.upload_img
= image_tag url_for(@user.avatar)
.text-center
= link_to 'Редагувати', edit_user_path, class: 'btn btn-success btn-lg'
...@@ -31,5 +31,5 @@ Devise.setup do |config| ...@@ -31,5 +31,5 @@ Devise.setup do |config|
config.omniauth :google_oauth2, "444952886435-8s76oeuc53otc8q84jork9mq4php7e7t.apps.googleusercontent.com", config.omniauth :google_oauth2, "444952886435-8s76oeuc53otc8q84jork9mq4php7e7t.apps.googleusercontent.com",
"vfJkP71fOkfDKVYa3RgXR3lW", {} "vfJkP71fOkfDKVYa3RgXR3lW", {}
config.omniauth :linkedin, "860rz2x1z3udrb", "peK2u8waxWK5h3Bq",{} config.omniauth :twitter, "c1uSeo1pm9Il2xLC6o8hIAv68", "JmCnAwaeZZjtZJcXcQzrfqmg5L4mMTJHuNsOaQnamVkVXJtcQN"
end end
\ No newline at end of file
en:
body:
title: 'teple misto platform'
title_highlighted: 'The city space is created by its citizens'
btn_main: 'donate'
joined people: 'joined people'
\ No newline at end of file
uk:
body:
title: 'Середовище Тепле Місто'
title_highlighted: 'Простір міста формюють його жителі'
btn_main: 'Підтримати'
joined_people: 'Обєднаних людей'
colected_money: 'Зібраних коштів (грн)'
\ No newline at end of file
en:
header:
platfform: 'about platform'
grants: 'grants'
projects: 'projects'
partners: 'partners'
digital: 'digital workshop'
about_us: 'about us'
news: 'news'
reports: 'reports'
people: 'People'
businesses: 'Businesses'
find_by_name: 'Find by name'
\ No newline at end of file
uk:
header:
platfform: 'про платформу'
grants: 'Ґранти'
projects: 'Проекти'
partners: 'Партнери'
digital: 'DIGITAL WORKSHOP'
about_us: 'Про нас'
news: 'Новини'
reports: 'Звіти'
people: 'Люди'
businesses: 'Бізнеси'
find_by_name: 'Пошук за іменем...'
\ No newline at end of file
en:
header:
platfform: 'about platform'
grants: 'grants'
projects: 'projects'
partners: 'partners'
digital: 'digital workshop'
about_us: 'about us'
news: 'news'
reports: 'reports'
find_by_name: 'Find by name'
\ No newline at end of file
uk:
header:
platfform: 'про платформу'
grants: 'Ґранти'
projects: 'Проекти'
partners: 'Партнери'
digital: 'DIGITAL WORKSHOP'
about_us: 'Про нас'
news: 'Новини'
reports: 'Звіти'
find_by_name: 'Пошук за іменем...'
Rails.application.routes.draw do Rails.application.routes.draw do
scope "(:locale)", locale: /en|uk/ do
root 'home#index' root 'home#index'
resources :users
end
devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks", devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks",
registrations: "users"} registrations: "users"}
resources :users
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment