Merge branch 'sidekiq-migrate'
This commit is contained in:
commit
87396cfde3
1
Gemfile
1
Gemfile
|
@ -7,6 +7,7 @@ gem 'pg'
|
||||||
gem 'schema_plus'
|
gem 'schema_plus'
|
||||||
########
|
########
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
|
gem 'omniauth-github'
|
||||||
gem 'pundit'
|
gem 'pundit'
|
||||||
gem 'rbtrace'
|
gem 'rbtrace'
|
||||||
|
|
||||||
|
|
21
Gemfile.lock
21
Gemfile.lock
|
@ -169,6 +169,7 @@ GEM
|
||||||
actionpack (>= 3.2, < 5)
|
actionpack (>= 3.2, < 5)
|
||||||
activesupport (>= 3.2, < 5)
|
activesupport (>= 3.2, < 5)
|
||||||
hashdiff (0.3.0)
|
hashdiff (0.3.0)
|
||||||
|
hashie (3.4.2)
|
||||||
hirb (0.7.3)
|
hirb (0.7.3)
|
||||||
html2haml (2.0.0)
|
html2haml (2.0.0)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
|
@ -197,6 +198,7 @@ GEM
|
||||||
railties (>= 3.2)
|
railties (>= 3.2)
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
|
jwt (1.5.0)
|
||||||
kaminari (0.17.0)
|
kaminari (0.17.0)
|
||||||
actionpack (>= 3.0.0)
|
actionpack (>= 3.0.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
|
@ -238,6 +240,7 @@ GEM
|
||||||
key_struct (~> 0.4)
|
key_struct (~> 0.4)
|
||||||
msgpack (0.7.6)
|
msgpack (0.7.6)
|
||||||
multi_json (1.12.1)
|
multi_json (1.12.1)
|
||||||
|
multi_xml (0.5.5)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
nest (1.1.2)
|
nest (1.1.2)
|
||||||
redis
|
redis
|
||||||
|
@ -248,6 +251,12 @@ GEM
|
||||||
rails (>= 3.1)
|
rails (>= 3.1)
|
||||||
nokogiri (1.6.7.2)
|
nokogiri (1.6.7.2)
|
||||||
mini_portile2 (~> 2.0.0.rc2)
|
mini_portile2 (~> 2.0.0.rc2)
|
||||||
|
oauth2 (1.0.0)
|
||||||
|
faraday (>= 0.8, < 0.10)
|
||||||
|
jwt (~> 1.0)
|
||||||
|
multi_json (~> 1.3)
|
||||||
|
multi_xml (~> 0.5)
|
||||||
|
rack (~> 1.2)
|
||||||
octokit (4.3.0)
|
octokit (4.3.0)
|
||||||
sawyer (~> 0.7.0, >= 0.5.3)
|
sawyer (~> 0.7.0, >= 0.5.3)
|
||||||
ohm (1.3.2)
|
ohm (1.3.2)
|
||||||
|
@ -256,6 +265,15 @@ GEM
|
||||||
scrivener (~> 0.0.3)
|
scrivener (~> 0.0.3)
|
||||||
ohm-expire (0.1.3.2)
|
ohm-expire (0.1.3.2)
|
||||||
ohm (>= 0.1.5)
|
ohm (>= 0.1.5)
|
||||||
|
omniauth (1.2.2)
|
||||||
|
hashie (>= 1.2, < 4)
|
||||||
|
rack (~> 1.0)
|
||||||
|
omniauth-github (1.1.2)
|
||||||
|
omniauth (~> 1.0)
|
||||||
|
omniauth-oauth2 (~> 1.1)
|
||||||
|
omniauth-oauth2 (1.3.0)
|
||||||
|
oauth2 (~> 1.0)
|
||||||
|
omniauth (~> 1.2)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
paperclip (4.3.6)
|
paperclip (4.3.6)
|
||||||
activemodel (>= 3.2.0)
|
activemodel (>= 3.2.0)
|
||||||
|
@ -567,6 +585,7 @@ DEPENDENCIES
|
||||||
octokit (~> 4.0)
|
octokit (~> 4.0)
|
||||||
ohm (~> 1.3.2)
|
ohm (~> 1.3.2)
|
||||||
ohm-expire (~> 0.1.3)
|
ohm-expire (~> 0.1.3)
|
||||||
|
omniauth-github
|
||||||
paperclip
|
paperclip
|
||||||
pg
|
pg
|
||||||
puma
|
puma
|
||||||
|
@ -612,4 +631,4 @@ DEPENDENCIES
|
||||||
will_paginate
|
will_paginate
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.11.2
|
1.13.1
|
||||||
|
|
|
@ -362,7 +362,6 @@ ul.sidebar .sidebar-list .menu-icon {
|
||||||
}
|
}
|
||||||
.sidebar-footer {
|
.sidebar-footer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 40px;
|
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
|
|
||||||
|
def github
|
||||||
|
oauthorize 'GitHub'
|
||||||
|
end
|
||||||
|
|
||||||
|
def passthru
|
||||||
|
render file: "#{Rails.root}/public/404.html", status: 404, layout: false
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def oauthorize(kind)
|
||||||
|
provider = kind.downcase
|
||||||
|
@user = find_for_ouath(env["omniauth.auth"], current_user)
|
||||||
|
if @user && @user.persisted?
|
||||||
|
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: action_name.classify
|
||||||
|
sign_in_and_redirect @user, event: :authentication
|
||||||
|
else
|
||||||
|
session["devise.#{provider}_data"] = env["omniauth.auth"]
|
||||||
|
redirect_to new_user_registration_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_for_ouath(auth, resource=nil)
|
||||||
|
provider, uid = auth['provider'], auth['uid']
|
||||||
|
authentication = Authentication.find_or_initialize_by(provider: provider, uid: uid)
|
||||||
|
if authentication.new_record?
|
||||||
|
if user_signed_in? # New authentication method for current_user
|
||||||
|
authentication.user = current_user
|
||||||
|
else # Register new user from session
|
||||||
|
case provider
|
||||||
|
when 'github'
|
||||||
|
name = auth['info']['nickname'] || auth['info']['name']
|
||||||
|
else
|
||||||
|
raise ActiveRecord::RecordNotFound
|
||||||
|
end
|
||||||
|
user = User.find_or_initialize_by email: auth['info']['email']
|
||||||
|
if user.new_record?
|
||||||
|
user.name = name
|
||||||
|
user.uname = name.gsub(/\s/, '').underscore
|
||||||
|
user.password = Devise.friendly_token[0,20]
|
||||||
|
user.confirmed_at = Time.zone.now
|
||||||
|
user.save
|
||||||
|
end
|
||||||
|
authentication.user = user
|
||||||
|
end
|
||||||
|
authentication.save
|
||||||
|
end
|
||||||
|
return authentication.user
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -15,6 +15,7 @@ class User < Avatar
|
||||||
|
|
||||||
devise :database_authenticatable, :registerable, :recoverable,
|
devise :database_authenticatable, :registerable, :recoverable,
|
||||||
:rememberable, :validatable, :lockable, :confirmable
|
:rememberable, :validatable, :lockable, :confirmable
|
||||||
|
devise :omniauthable, omniauth_providers: %i(github)
|
||||||
|
|
||||||
has_one :notifier, class_name: 'SettingsNotifier', dependent: :destroy #:notifier
|
has_one :notifier, class_name: 'SettingsNotifier', dependent: :destroy #:notifier
|
||||||
has_one :builds_setting, class_name: 'UserBuildsSetting', dependent: :destroy
|
has_one :builds_setting, class_name: 'UserBuildsSetting', dependent: :destroy
|
||||||
|
|
|
@ -17,3 +17,5 @@
|
||||||
= f.button :submit, t('layout.devise.shared_links.sign_in')
|
= f.button :submit, t('layout.devise.shared_links.sign_in')
|
||||||
.row
|
.row
|
||||||
= link_to t('layout.devise.shared_links.forgot_password'), new_password_path(resource_name)
|
= link_to t('layout.devise.shared_links.forgot_password'), new_password_path(resource_name)
|
||||||
|
rd-widget-footer
|
||||||
|
== render 'devise/shared/providers'
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
- if devise_mapping.omniauthable?
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.pull-left
|
||||||
|
= t('.sign_up_with')
|
||||||
|
.pull-right
|
||||||
|
- resource_class.omniauth_providers.each do |provider|
|
||||||
|
a.text-muted> href=omniauth_authorize_path(resource_name, provider)
|
||||||
|
i.fa.fa-2x class="fa-#{provider}-square"
|
|
@ -5,3 +5,5 @@
|
||||||
= link_to t('bottom_menu.contacts'), t('bottom_menu.contacts_url')
|
= link_to t('bottom_menu.contacts'), t('bottom_menu.contacts_url')
|
||||||
.col-xs-4
|
.col-xs-4
|
||||||
= link_to t('bottom_menu.support'), contact_url
|
= link_to t('bottom_menu.support'), contact_url
|
||||||
|
.col-xs-12
|
||||||
|
= link_to t('bottom_menu.tos'), 'https://www.openmandriva.org/tos'
|
||||||
|
|
|
@ -184,6 +184,7 @@ Devise.setup do |config|
|
||||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||||
# up on your models and hooks.
|
# up on your models and hooks.
|
||||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||||
|
config.omniauth :github, APP_CONFIG['keys']['github']['id'], APP_CONFIG['keys']['github']['secret'], scope: 'user:email'
|
||||||
|
|
||||||
# require 'openid/store/filesystem'
|
# require 'openid/store/filesystem'
|
||||||
# config.omniauth :openid, :name => 'open_id' #, :store => OpenID::Store::Filesystem.new('./tmp')
|
# config.omniauth :openid, :name => 'open_id' #, :store => OpenID::Store::Filesystem.new('./tmp')
|
||||||
|
|
|
@ -10,6 +10,9 @@ en:
|
||||||
other: "%{count} errors prevented %{resource} from being saved:"
|
other: "%{count} errors prevented %{resource} from being saved:"
|
||||||
|
|
||||||
devise:
|
devise:
|
||||||
|
shared:
|
||||||
|
providers:
|
||||||
|
sign_up_with: 'or sign in with'
|
||||||
failure:
|
failure:
|
||||||
already_authenticated: 'You are already signed in.'
|
already_authenticated: 'You are already signed in.'
|
||||||
unauthenticated: 'You need to sign in or sign up before continuing.'
|
unauthenticated: 'You need to sign in or sign up before continuing.'
|
||||||
|
|
|
@ -12,6 +12,9 @@ ru:
|
||||||
other: "%{resource}: сохранение не удалось из-за %{count} ошибки"
|
other: "%{resource}: сохранение не удалось из-за %{count} ошибки"
|
||||||
|
|
||||||
devise:
|
devise:
|
||||||
|
shared:
|
||||||
|
providers:
|
||||||
|
sign_up_with: 'или войти с помощью'
|
||||||
failure:
|
failure:
|
||||||
already_authenticated: 'Вы уже вошли в систему.'
|
already_authenticated: 'Вы уже вошли в систему.'
|
||||||
unauthenticated: "Вам необходимо войти в систему или зарегистрироваться."
|
unauthenticated: "Вам необходимо войти в систему или зарегистрироваться."
|
||||||
|
|
|
@ -21,11 +21,13 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
get 'users/sign_up' => 'users/registrations#new', as: :new_user_registration
|
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
||||||
post 'users' => 'users/registrations#create', as: :user_registration
|
get 'users/sign_up' => 'users/registrations#new', as: :new_user_registration
|
||||||
|
post 'users' => 'users/registrations#create', as: :user_registration
|
||||||
end
|
end
|
||||||
|
|
||||||
devise_for :users, controllers: {
|
devise_for :users, controllers: {
|
||||||
|
omniauth_callbacks: 'users/omniauth_callbacks',
|
||||||
confirmations: 'users/confirmations'
|
confirmations: 'users/confirmations'
|
||||||
}, skip: [:registrations]
|
}, skip: [:registrations]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue