[#247] remove private users
This commit is contained in:
parent
8f75f1b077
commit
636ae022bf
|
@ -1,31 +0,0 @@
|
|||
class Platforms::PrivateUsersController < Platforms::BaseController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_platform_and_private_users
|
||||
|
||||
load_and_authorize_resource :platform
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def create
|
||||
old_pair = PrivateUser.find_by_platform_id_and_user_id(params[:platform_id], current_user.id)
|
||||
old_pair.destroy if old_pair
|
||||
|
||||
@pair = PrivateUser.generate_pair(params[:platform_id], current_user.id)
|
||||
@urpmi_list = @platform.urpmi_list(request.host, @pair)
|
||||
redirect_to platform_private_users_path(params[:platform_id]), notice: I18n.t('flash.private_users', login: @pair[:login], password: @pair[:pass])
|
||||
end
|
||||
|
||||
#def destroy
|
||||
# user = PrivateUser.find(params[:id])
|
||||
# user.destroy
|
||||
# redirect_to platform_private_users_path(params[:platform_id])
|
||||
#end
|
||||
|
||||
protected
|
||||
|
||||
def find_platform_and_private_users
|
||||
@private_users = PrivateUser.where(platform_id: params[:platform_id]).paginate page: params[:page]
|
||||
@platform = Platform.find(params[:platform_id])
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
class Platforms::PrivatesController < Platforms::BaseController
|
||||
require 'digest/sha2'
|
||||
|
||||
before_filter :find_platform
|
||||
before_filter :authenticate
|
||||
|
||||
def show
|
||||
file_name = "#{APP_CONFIG['root_path']}/platforms/#{params[:platform_name]}/#{params[:file_path]}"
|
||||
|
||||
if File.directory?(file_name) || !File.exists?(file_name)
|
||||
render file: "#{Rails.root}/public/404.html", layout: false, status: 404
|
||||
else
|
||||
send_file file_name
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def authenticate
|
||||
authenticate_or_request_with_http_basic do |username, password|
|
||||
PrivateUser.exists?(
|
||||
login: username,
|
||||
password: Digest::SHA2.new.hexdigest(password),
|
||||
platform_id: @platform.try(:id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def find_platform
|
||||
@platform = Platform.find_by_name(params[:platform_name])
|
||||
end
|
||||
end
|
|
@ -140,9 +140,6 @@ class Ability
|
|||
can([:create, :cancel, :update], ProductBuildList) {|pbl| can?(:update, pbl.product)}
|
||||
can(:destroy, ProductBuildList) {|pbl| can?(:destroy, pbl.product)}
|
||||
|
||||
can [:read, :create], PrivateUser, platform: {owner_type: 'User', owner_id: user.id}
|
||||
can [:read, :create], PrivateUser, platform: {owner_type: 'Group', owner_id: user_group_ids}
|
||||
|
||||
can :read, Issue, project: {owner_type: 'User', owner_id: user.id}
|
||||
can :read, Issue, project: {owner_type: 'Group', owner_id: user_group_ids}
|
||||
can(:read, Issue, read_relations_for('issues', 'projects')) {|issue| can? :read, issue.project rescue nil}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class EventLogObserver < ActiveRecord::Observer
|
||||
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :product_build_list
|
||||
observe :user, :platform, :repository, :project, :product, :build_list, :product_build_list
|
||||
|
||||
def after_create(record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
class PrivateUser < ActiveRecord::Base
|
||||
require 'digest/sha2'
|
||||
|
||||
belongs_to :platform
|
||||
belongs_to :user
|
||||
|
||||
validate :login, uniqueness: true
|
||||
|
||||
def event_log_message
|
||||
{platform: platform.name, user: user.uname}.inspect
|
||||
end
|
||||
|
||||
class << self
|
||||
def can_generate_more?(user_id, platform_id)
|
||||
!PrivateUser.exists?(user_id: user_id, platform_id: platform_id)
|
||||
end
|
||||
|
||||
def generate_pair(platform_id, user_id)
|
||||
login = "login_#{ActiveSupport::SecureRandom.hex(16)}"
|
||||
pass = "pass_#{ActiveSupport::SecureRandom.hex(16)}"
|
||||
|
||||
PrivateUser.create(
|
||||
login: login,
|
||||
password: Digest::SHA2.new.hexdigest(pass),
|
||||
platform_id: platform_id,
|
||||
user_id: user_id
|
||||
)
|
||||
|
||||
{login: login, pass: pass}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -34,6 +34,3 @@
|
|||
= link_to t("layout.key_pairs.header"), platform_key_pairs_path(@platform)
|
||||
%li{class: (contr == :tokens) ? 'active' : ''}
|
||||
= link_to t('layout.tokens.header'), platform_tokens_path(@platform)
|
||||
-#- if current_user.owner_of? @platform or current_user.admin?
|
||||
%li{class: (act == :index && contr == :private_users) ? 'active' : ''}
|
||||
= link_to t("layout.platforms.private_users"), platform_private_users_path(@platform)
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
-set_meta_tags title: [title_object(current_user.repository), t('layout.personal_repositories.private_users')]
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.personal_repositories.show"), personal_repository_path(current_user.personal_repository)
|
||||
%li= link_to t("layout.personal_repositories.settings"), settings_personal_repository_path(current_user.personal_repository)
|
||||
%li.active= link_to t("layout.personal_repositories.private_users"), platform_private_users_path(current_user.personal_platform) if current_user.personal_platform.hidden?
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.platform.name")
|
||||
\:
|
||||
= @platform.name
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.repository.platform")
|
||||
\:
|
||||
= link_to @platform.name, platform_path(@platform)
|
||||
|
||||
- if @urpmi_list
|
||||
= render 'shared/urpmi_list', urpmi_commands: @urpmi_list
|
||||
.wat-cf
|
||||
=# link_to image_tag("x.png", alt: t("layout.delete")) + " " + t("layout.delete"), platform_repository_path(@platform, @repository), method: "delete", class: "button", confirm: t("layout.repositories.confirm_delete")
|
||||
%br
|
||||
.inner
|
||||
=t('layout.private_users.warning_message')
|
||||
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.private_users.list"), platform_private_users_path(@platform)
|
||||
%li= link_to t("layout.private_users.new"), platform_private_users_path(@platform), method: :post if PrivateUser.can_generate_more?(current_user.id, @platform.id)
|
||||
.content
|
||||
%h2.title
|
||||
= t("layout.private_users.list_header")
|
||||
.inner
|
||||
%table.table
|
||||
%tr
|
||||
%th.first= t("activerecord.attributes.private_user.login")
|
||||
%th.last
|
||||
- @private_users.each do |private_user|
|
||||
%tr{class: cycle("odd", "even")}
|
||||
%td
|
||||
= private_user.login
|
||||
%td.last
|
||||
#{link_to t("layout.private_users.regenerate_btn"), platform_private_users_path(@platform), method: :post, confirm: t("layout.private_users.confirm_regenerate")}
|
||||
.actions-bar.wat-cf
|
||||
.actions
|
||||
= will_paginate @private_users
|
|
@ -91,15 +91,6 @@ en:
|
|||
sign_in_header: Sign in
|
||||
sign_up_with: or sign in with
|
||||
|
||||
private_users:
|
||||
list: List
|
||||
new: New pair
|
||||
list_header: Pair login/password
|
||||
confirm_delete: Are you sure to delete this pair login/password?
|
||||
confirm_regenerate: Are you sure to regenerate this pair login/password?
|
||||
regenerate_btn: Regenerate
|
||||
warning_message: Warning - Old data set as invalid when new data obtaining
|
||||
|
||||
collaborators:
|
||||
back_to_proj: Back to project
|
||||
edit: Edit list
|
||||
|
@ -132,8 +123,6 @@ en:
|
|||
saved: Settings saved success
|
||||
save_error: Setting update error
|
||||
|
||||
private_users: "Login: %{login} Password: %{password}"
|
||||
|
||||
subscribe:
|
||||
saved: Subscription on notifications for this task is created
|
||||
saved_error: Subscription create error
|
||||
|
@ -177,7 +166,6 @@ en:
|
|||
can_have_less_or_equal: You cannot have more than %{count} projects.
|
||||
|
||||
models:
|
||||
private_user: Private user
|
||||
product_build_list: Product build list
|
||||
|
||||
attributes:
|
||||
|
@ -195,10 +183,6 @@ en:
|
|||
new_build: Notify about my build tasks
|
||||
new_associated_build: Notify about associated with me build tasks
|
||||
|
||||
private_user:
|
||||
login: Login
|
||||
password: Password
|
||||
|
||||
arch:
|
||||
name: Name
|
||||
created_at: Created
|
||||
|
|
|
@ -11,7 +11,6 @@ en:
|
|||
'devise/sessions_controller': 'User Authentication'
|
||||
'devise/passwords_controller': 'Password recovery'
|
||||
'users/omniauth_callbacks_controller': 'External users authentication'
|
||||
private_users_controller: 'access to private repositories'
|
||||
personal_repositories_controller: 'Personal repositories management'
|
||||
actions:
|
||||
'devise/sessions_controller':
|
||||
|
@ -27,9 +26,6 @@ en:
|
|||
create: 'sent to build'
|
||||
rpc_controller:
|
||||
xe_index: inquiry
|
||||
private_users_controller:
|
||||
create: 'given'
|
||||
destroy: 'deleted'
|
||||
personal_repositories_controller:
|
||||
change_visibility: 'status change'
|
||||
create: 'created'
|
||||
|
|
|
@ -11,7 +11,6 @@ ru:
|
|||
'devise/sessions_controller': 'Аутентификация пользователей'
|
||||
'devise/passwords_controller': 'Восстановление пароля'
|
||||
'users/omniauth_callbacks_controller': 'Внешняя аутентификация пользователей'
|
||||
private_users_controller: 'Доступ к приватным репозиториям'
|
||||
personal_repositories_controller: 'Управление персональными репозиториями'
|
||||
actions:
|
||||
'devise/sessions_controller':
|
||||
|
@ -27,9 +26,6 @@ ru:
|
|||
create: 'отправлен на сборку'
|
||||
rpc_controller:
|
||||
xe_index: запрос
|
||||
private_users_controller:
|
||||
create: 'предоставлен'
|
||||
destroy: 'удален'
|
||||
personal_repositories_controller:
|
||||
change_visibility: 'смена статуса'
|
||||
create: 'создано'
|
||||
|
|
|
@ -35,7 +35,6 @@ en:
|
|||
visibility: Visibility
|
||||
platform_type: Platform type
|
||||
distrib_type: Distribution type
|
||||
private_users: Access data
|
||||
confirm_clone: Clone?
|
||||
clone: Clone
|
||||
delete_warning: Attention! Deleted platform can not be restored!
|
||||
|
|
|
@ -35,7 +35,6 @@ ru:
|
|||
visibility: Видимость
|
||||
platform_type: Тип платформы
|
||||
distrib_type: Тип дистрибутива
|
||||
private_users: Данные для доступа
|
||||
confirm_clone: Клонировать?
|
||||
clone: Клонировать
|
||||
delete_warning: Внимание! Удаленная платформа восстановлению не подлежит.
|
||||
|
|
|
@ -91,15 +91,6 @@ ru:
|
|||
sign_in_header: Вход в систему
|
||||
sign_up_with: или войти с помощью
|
||||
|
||||
private_users:
|
||||
list: Список
|
||||
new: Новая пара
|
||||
list_header: Пары логин/пароль
|
||||
confirm_delete: Вы уверены, что хотите удалить эту пару логин/пароль?
|
||||
confirm_regenerate: Вы уверены, что хотите перегенерировать эту пару логин/пароль?
|
||||
regenerate_btn: Перегенерировать
|
||||
warning_message: Примечание - При получении новых данных старые становятся недействительными
|
||||
|
||||
collaborators:
|
||||
back_to_proj: Вернуться к проекту
|
||||
edit: Редактировать список
|
||||
|
@ -132,8 +123,6 @@ ru:
|
|||
saved: Настройки успешно сохранены
|
||||
save_error: При обновлении настроек произошла ошибка
|
||||
|
||||
private_users: "Логин: %{login} Пароль: %{password}"
|
||||
|
||||
subscribe:
|
||||
saved: Вы подписаны на оповещения для этой задачи
|
||||
saved_error: При создании подписки произошла ошибка
|
||||
|
@ -177,7 +166,6 @@ ru:
|
|||
can_have_less_or_equal: Нельзя иметь больше, чем %{count} проектов.
|
||||
|
||||
models:
|
||||
private_user: Приватный пользователь
|
||||
product_build_list: Сборочный лист продукта
|
||||
|
||||
attributes:
|
||||
|
@ -195,10 +183,6 @@ ru:
|
|||
new_build: Оповещать о моих сборочных заданиях
|
||||
new_associated_build: Оповещать о связанных со мной сборочных заданиях
|
||||
|
||||
private_user:
|
||||
login: Логин
|
||||
password: Пароль
|
||||
|
||||
arch:
|
||||
name: Название
|
||||
created_at: Создана
|
||||
|
|
|
@ -165,7 +165,6 @@ Rosa::Application.routes.draw do
|
|||
|
||||
scope module: 'platforms' do
|
||||
resources :platforms, constraints: {id: Platform::NAME_PATTERN} do
|
||||
resources :private_users, except: [:show, :destroy, :update]
|
||||
member do
|
||||
put :regenerate_metadata
|
||||
put :clear
|
||||
|
@ -221,7 +220,6 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
resources :maintainers, only: [:index]
|
||||
end
|
||||
match '/private/:platform_name/*file_path' => 'privates#show'
|
||||
|
||||
resources :product_build_lists, only: [:index, :show]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class DestroyPrivateUser < ActiveRecord::Migration
|
||||
def self.up
|
||||
drop_table :private_users
|
||||
end
|
||||
|
||||
def self.down
|
||||
create_table :private_users do |t|
|
||||
t.integer :platform_id
|
||||
t.string :login
|
||||
t.string :password
|
||||
t.integer :user_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140224134012) do
|
||||
ActiveRecord::Schema.define(:version => 20140306102620) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -285,7 +285,6 @@ ActiveRecord::Schema.define(:version => 20140224134012) do
|
|||
t.string "arch_names"
|
||||
t.integer "user_id"
|
||||
t.boolean "auto_publish", :default => false, :null => false
|
||||
t.integer "build_lists_count", :default => 0, :null => false
|
||||
t.boolean "stop_build", :default => false, :null => false
|
||||
t.text "projects_list"
|
||||
t.integer "missed_projects_count", :default => 0, :null => false
|
||||
|
@ -295,6 +294,7 @@ ActiveRecord::Schema.define(:version => 20140224134012) do
|
|||
t.text "extra_repositories"
|
||||
t.text "extra_build_lists"
|
||||
t.boolean "increase_release_tag", :default => false, :null => false
|
||||
t.integer "build_lists_count", :default => 0
|
||||
end
|
||||
|
||||
create_table "platform_arch_settings", :force => true do |t|
|
||||
|
@ -329,15 +329,6 @@ ActiveRecord::Schema.define(:version => 20140224134012) do
|
|||
|
||||
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
|
||||
|
||||
create_table "private_users", :force => true do |t|
|
||||
t.integer "platform_id"
|
||||
t.string "login"
|
||||
t.string "password"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "product_build_lists", :force => true do |t|
|
||||
t.integer "product_id"
|
||||
t.integer "status", :null => false
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Platforms::PrivateUsersController do
|
||||
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Platforms::PrivatesController do
|
||||
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
FactoryGirl.define do
|
||||
factory :private_user do
|
||||
login { FactoryGirl.generate(:string) }
|
||||
password { FactoryGirl.generate(:string) }
|
||||
association :platform, factory: :platform
|
||||
association :user, factory: :user
|
||||
end
|
||||
end
|
|
@ -130,21 +130,6 @@ describe CanCan do
|
|||
@ability.should_not be_able_to(:manage, RegisterRequest)
|
||||
end
|
||||
|
||||
context "private users relations" do
|
||||
before(:each) do
|
||||
@private_user = FactoryGirl.create(:private_user)
|
||||
|
||||
@private_user.platform.owner = @user
|
||||
@private_user.platform.save
|
||||
end
|
||||
|
||||
[:read, :create].each do |action|
|
||||
it "should be able to #{ action } PrivateUser" do
|
||||
@ability.should be_able_to(action, @private_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'as project collaborator' do
|
||||
before(:each) do
|
||||
@project = FactoryGirl.create(:project_with_commit)
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PrivateUser do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue