Commit 084024ae authored by Kimia Mirehbar's avatar Kimia Mirehbar Committed by Francesc Guasch
Browse files

change settings of own machines grant

parent bf422e47
......@@ -101,9 +101,7 @@ init();
hook before_routes => sub {
my $c = shift;
my $version = $RAVADA->version();
$version =~ s/-/_/g;
$c->stash(version => $version);
$c->stash(version => $RAVADA->version."$VERSION_TYPE");
my $url = $c->req->url->to_abs->path;
$c->stash(css=>['/css/sb-admin.css']
,js=>[
......@@ -123,7 +121,7 @@ hook before_routes => sub {
return login($c)
if
$url !~ m{^/(anonymous|login|logout|requirements|robots.txt)}
$url !~ m{^/(anonymous|login|logout|requirements)}
&& $url !~ m{^/(css|font|img|js)}
&& !_logged_in($c);
......@@ -133,12 +131,6 @@ hook before_routes => sub {
############################################################################3
any '/robots.txt' => sub {
my $c = shift;
warn "robots";
return $c->render(text => "User-agent: *\nDisallow: /\n", format => 'text');
};
any '/' => sub {
my $c = shift;
return quick_start($c);
......@@ -209,15 +201,12 @@ any '/admin/(#type)' => sub {
my $c = shift;
return access_denied($c) if !$USER->is_admin;
return admin($c);
};
any '/new_machine' => sub {
my $c = shift;
return access_denied($c) if !$USER->is_admin;
return access_denied($c) if !$USER->can_create_domain;
return new_machine($c);
};
......@@ -304,7 +293,9 @@ get '/machine/info/(:id).(:type)' => sub {
};
any '/machine/settings/(:id).(:type)' => sub {
return settings_machine(@_);
my $c = shift;
return access_denied($c) if !$USER->can_change_settings();
return settings_machine($c);
};
any '/machine/manage/(:id).(:type)' => sub {
......@@ -936,7 +927,6 @@ sub new_machine {
sub req_new_domain {
my $c = shift;
my $name = $c->param('name');
my $vm = ( $c->param('backend') or 'KVM');
my $swap = ($c->param('swap') or 0);
$swap *= 1024*1024*1024;
my %args = (
......@@ -1213,6 +1203,8 @@ sub init {
sub _search_requested_machine {
my $c = shift;
confess "Missing \$c" if !defined $c;
my $id = $c->stash('id');
my $type = $c->stash('type');
......@@ -1246,24 +1238,33 @@ sub register {
my $username = $c->param('username');
my $password = $c->param('password');
if($username) {
my @list_users = Ravada::Auth::SQL::list_all_users();
warn join(", ", @list_users);
if (grep {$_ eq $username} @list_users) {
push @error,("Username already exists, please choose another one");
$c->render(template => 'bootstrap/new_user',error => \@error);
}
else {
#username don't exists
Ravada::Auth::SQL::add_user(name => $username, password => $password);
return $c->render(template => 'bootstrap/new_user_ok' , username => $username);
}
# if($c ->param('submit')) {
# push @error,("Name is mandatory") if !$c->param('username');
# push @error,("Invalid username '".$c->param('username')."'"
# .".It can only contain words and numbers.")
# if $c->param('username') && $c->param('username') !~ /^[a-zA-Z0-9]+$/;
# if (!@error) {
# Ravada::Auth::SQL::add_user($username, $password,0);
# return $c->render(template => 'bootstrap/new_user_ok' , username => $username);
# }
# }
# $c->stash(errors => \@error);
# push @{$c->stash->{js}}, '/js/admin.js';
# $c->render(template => 'bootstrap/new_user_control'
# , name => $c->param('username')
#)
if ($username) {
Ravada::Auth::SQL::add_user(name => $username, password => $password);
return $c->render(template => 'bootstrap/new_user_ok' , username => $username);
}
$c->render(template => 'bootstrap/new_user',error => \@error);
$c->render(template => 'bootstrap/new_user');
}
sub manage_machine {
my $c = shift;
return login($c) if !_logged_in($c);
......
......@@ -87,7 +87,9 @@
% }
% if ( $machine->{id_clone}) {
% if ($_user->can_change_settings){
<a align="right" href="/machine/settings/<%= $machine->{id_clone} %>.html"><i class="fa fa-fw fa-cog" title="<%=l 'Settings' %>"></a></i>
% }
<div ng-show="host_restore == <%= $machine->{id_clone} %>">
<b><%=l 'Restore' %></b> <%=l 'will remove all the contents of the machine' %>
<i><b><%= $machine->{name_clone} %></b></i>.
......
Supports Markdown
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