33 lines
1.2 KiB
Ruby
33 lines
1.2 KiB
Ruby
class PrivateUsersController < ApplicationController
|
|
before_filter :authenticate_user!
|
|
before_filter :check_global_access, :except => [:destroy]
|
|
before_filter :find_platform_and_private_users
|
|
|
|
def index
|
|
@private_users = PrivateUser.where(:platform_id => params[:platform_id]).paginate :page => params[:page]
|
|
@platform = Platform.find(params[:platform_id])
|
|
end
|
|
|
|
def create
|
|
@pair = PrivateUser.generate_pair(params[:platform_id], current_user.id)
|
|
@urpmi_list = @platform.urpmi_list(request.host, @pair).join(' / ')
|
|
#redirect_to platform_private_users_path(params[:platform_id]), :notice => "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }"
|
|
flash[:notice] = "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }"
|
|
render :action => 'index'
|
|
end
|
|
|
|
def destroy
|
|
user = PrivateUser.find(params[:id])
|
|
can_perform? user if user
|
|
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
|