Sha256: 42a0f621ee097834e9db99cb552a3619f4ea54148dd03b4b6204e2fa7e869c89

Contents?: true

Size: 1.9 KB

Versions: 19

Compression:

Stored size: 1.9 KB

Contents

class RhosyncConsole::Server
  get '/users' do
    @users = []
    handle_api_error("Can't load list of users") do
      @users = RhosyncApi::list_users(session[:server],session[:token])
    end
    erb :users
  end
  
  get '/user/new' do
    erb :newuser
  end
  
  post '/user/create' do
    session[:errors] = nil
    verify_presence_of :login, "Login is not provaided."
    unless session[:errors]             
      handle_api_error("Can't create new user") do  
        RhosyncApi::create_user(session[:server],
          session[:token],params[:login],params[:password])
      end      
    end
    redirect url(session[:errors] ? '/user/new' : '/users'), 303  
  end
  
  get '/user' do
    @devices = []
    handle_api_error("Can't load list of devices") do
      @devices = RhosyncApi::list_clients(
        session[:server],session[:token],params[:user_id])
    end
    @sources = []
    handle_api_error("Can't load list of user partition sources") do
      @sources = RhosyncApi::list_sources(session[:server],session[:token],:user)
    end
    erb :user
  end
  
  get '/user/delete' do
    handle_api_error("Can't delete user #{params[:user_id]}") do 
      RhosyncApi::delete_user(session[:server],session[:token],params[:user_id])
    end    
    redirect url(session[:errors] ? "/user?user_id=#{CGI.escape(params[:user_id])}" : '/users'), 303
  end
  
  get '/user/ping' do
    @sources = []
    handle_api_error("Can't load list of user partition sources") do
      @sources = RhosyncApi::list_sources(session[:server],session[:token],:all)
    end
    erb :ping
  end
  
  post '/user/ping' do
    params[:sources] = params[:sources].split(',')
    handle_api_error("Error while pinging") do
      RhosyncApi::ping(session[:server],session[:token],params[:user_id],params)
    end
    user = CGI.escape(params[:user_id])
    redirect url(session[:errors] ? "/user/ping?user_id=#{user}" : "/user?user_id=#{user}"), 303
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rhosync-2.0.5 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.4 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.3 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.2 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.1 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.rc2 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.rc1 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta13 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta12 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta11 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta10 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta9 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta8 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta7 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta6 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta4 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta3 lib/rhosync/console/app/routes/user.rb
rhosync-2.0.0.beta2 lib/rhosync/console/app/routes/user.rb