Commit f8b7ff2c by Mykhailo Makohin

some changes with user autentification

parent da22df9e
......@@ -18,7 +18,7 @@ gem 'devise'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-linkedin-oauth2'
gem 'omniauth-twitter'
gem 'haml'
gem 'bootstrap-sass'
gem 'gmaps4rails'
......
......@@ -103,6 +103,7 @@ GEM
nio4r (2.5.0)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
oauth (0.5.4)
oauth2 (1.4.1)
faraday (>= 0.8, < 0.16.0)
jwt (>= 1.0, < 3.0)
......@@ -120,9 +121,15 @@ GEM
omniauth-oauth2 (>= 1.6)
omniauth-linkedin-oauth2 (1.0.0)
omniauth-oauth2
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)
puma (3.12.1)
rack (2.0.7)
......@@ -227,6 +234,7 @@ DEPENDENCIES
omniauth-facebook
omniauth-google-oauth2
omniauth-linkedin-oauth2
omniauth-twitter
puma (~> 3.0)
rails (~> 5.0.7, >= 5.0.7.2)
remotipart
......
class ApplicationController < ActionController::Base
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
protect_from_forgery with: :exception
end
......@@ -5,12 +5,12 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
sign_in_with "Facebook"
end
def failure
redirect_to root_path
def twitter
sign_in_with "Twitter"
end
def linkedin
sign_in_with "LinkedIn"
def failure
redirect_to root_path
end
def google_oauth2
......
......@@ -16,8 +16,8 @@ class UsersController < ApplicationController
@user = User.find_or_create_by(user_params)
@user.skip_password_validation = true
if @user.save
redirect_to root_path
else
redirect_to edit_user_path(@user)
elsif
redirect_to root_path
end
end
......@@ -28,9 +28,12 @@ class UsersController < ApplicationController
def update
@user = resource
@user.skip_password_validation = false
if @user.update(user_params)
redirect_to user_path(user: @user)
sign_in @user
redirect_to user_path(@user)
else
puts @user.errors.messages
render :edit
end
end
......@@ -53,7 +56,8 @@ class UsersController < ApplicationController
end
def user_params
params.require(:user).permit(:email, :name, :location)
params.require(:user).permit(:email, :name, :location,
:password, :password_confirmation)
end
end
\ No newline at end of file
class User < ApplicationRecord
attr_accessor :skip_password_validation
validates :name, presence: true
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable, :omniauthable,
omniauth_providers: [:facebook, :google_oauth2, :linkedin]
omniauth_providers: [:facebook, :google_oauth2, :twitter]
def self.new_with_session(params, session)
super.tap do |user|
......
......@@ -6,11 +6,11 @@
#1.tab-pane.tab-pane_people.active
.main_head_title
= image_tag ("logo_lg.png")
%h1= t ("body.title")
.title_highlighted= t ("body.title_highlighted")
%h1 платформа тепле місто
.title_highlighted Простір міста формують його жителі
.tab-pane_content
.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
.counter
.counter_value
......@@ -33,7 +33,7 @@
.counter_digit
%span 0
.counter_gradient_top
.counter_text= t ("body.joined_people")
.counter_text об'єднаних людей
.counter.counter_violet
.counter_value
.counter_digit
......@@ -52,7 +52,7 @@
.counter_digit
%span 0
.counter_gradient_top
.counter_text= t ("body.colected_money")
.counter_text зібрано коштів
.cubes_wrap
.cubes_inner_wrap
#cube-wall.cube-wall
......
......@@ -13,21 +13,21 @@
#bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav
%li
%a{:href => "#"}= t ("header.platfform")
%a{:href => "#"} про платформу
%li
%a{:href => "#"}= t ("header.grants")
%a{:href => "#"} гранти
%li
%a{:href => "#"}= t ("header.projects")
%a{:href => "#"} проекти
%li
%a{:href => "#"}= t ("header.partners")
%a{:href => "#"} партнери
%li
%a{:href => "#"}= t ("header.digital")
%a{:href => "#"} digital workshop
%li
%a{:href => "#"}= t ("header.about_us")
%a{:href => "#"} про нас
%li
%a{:href => "#"}= t ("header.news")
%a{:href => "#"} новини
%li
%a{:href => "#"}= t ("header.reports")
%a{:href => "#"} звіти
%li
%a{:href => "#"} connectif
%li
......@@ -35,9 +35,9 @@
= link_to('Logout', destroy_user_session_path, method: :delete)
%ul.nav.nav-tabs.nav_btns
%li.active
%a{"data-toggle" => "tab", :href => "#1"}= t 'header.people'
%a{"data-toggle" => "tab", :href => "#1"} Люди
%li
%a{"data-toggle" => "tab", :href => "#2"}= t 'header.businesses'
%a{"data-toggle" => "tab", :href => "#2"} Бізнеси
.show_tip
Ознайомтесь з дружніми бізнесами
які допомагають формувати
......@@ -48,6 +48,6 @@
%button.login_btn{"data-target" => "#modal3", "data-toggle" => "modal"}
= image_tag ("login.png")
.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
%i.icon.icon_search
\ No newline at end of file
......@@ -10,8 +10,8 @@
.modal-header_bot
%h3#modalLabel.modal-title Вхід
.help_text.absolute
%span.asterisk *
Поля обов'язкові для заповнення
%span.asterisk> *
Всі поля обов'язкові для заповнення
.modal-body
.row
.col-sm-9.modal-body_login
......@@ -19,30 +19,28 @@
Авторизація
.form-group
%label{:for => "id_3"}
%span.asterisk> *
E-mail
.field_wrap
= f.input :email, class: 'form-control', label: false
.form-group
= f.email_field :email, class: 'form-control'
.form-group
%label{:for => "id_2"}
%span.asterisk> *
Ім'я та прізвище
.field_wrap
= f.input :name, class: 'form-control', label: false
= f.input_field :name, class: 'form-control'
.form-group
%label{:for => "user_location"}
%label{:for => "id_4"}
Населений пункт
.field_wrap
= f.input :location, class: 'form-control', label: ""
%input#id_4.form-control{:type => "text"}/
.col-sm-3.modal-body_registration
%h4.modal_subtitle
Швидка реєстрація
.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
%a.soc_btn.soc_btn_tw{href: "/users/auth/linkedin"}
%a.soc_btn.soc_btn_tw{:href => "/users/auth/twitter"}
%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
.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 @@
#bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav
%li
%a{:href => "#"}= t ("header.platfform")
%a{:href => "#"} про платформу
%li
%a{:href => "#"}= t ("header.grants")
%a{:href => "#"} гранти
%li
%a{:href => "#"}= t ("header.projects")
%a{:href => "#"} проекти
%li
%a{:href => "#"}= t ("header.partners")
%a{:href => "#"} партнери
%li
%a{:href => "#"}= t ("header.digital")
%a{:href => "#"} digital workshop
%li
%a{:href => "#"}= t ("header.about_us")
%a{:href => "#"} про нас
%li
%a{:href => "#"}= t ("header.news")
%a{:href => "#"} новини
%li
%a{:href => "#"}= t ("header.reports")
%a{:href => "#"} звіти
%li
%a{:href => "#"} connectif
%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|
config.omniauth :google_oauth2, "444952886435-8s76oeuc53otc8q84jork9mq4php7e7t.apps.googleusercontent.com",
"vfJkP71fOkfDKVYa3RgXR3lW", {}
config.omniauth :linkedin, "860rz2x1z3udrb", "peK2u8waxWK5h3Bq",{}
end
config.omniauth :twitter, "c1uSeo1pm9Il2xLC6o8hIAv68", "JmCnAwaeZZjtZJcXcQzrfqmg5L4mMTJHuNsOaQnamVkVXJtcQN"
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
scope "(:locale)", locale: /en|uk/ do
root 'home#index'
resources :users
end
devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks",
registrations: "users"}
root 'home#index'
devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks",
registrations: "users"}
resources :users
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