Putting everything behind /app
This commit is contained in:
parent
2001133b09
commit
bb5bcfc4e9
@ -24,18 +24,18 @@ sub startup ($self) {
|
||||
|
||||
# Normal route to controller
|
||||
my $routes = $r->under(
|
||||
'/',
|
||||
'/app',
|
||||
sub {
|
||||
my $c = shift;
|
||||
my $redirect_login = sub {
|
||||
my $c = shift;
|
||||
my $url = Mojo::URL->new('/login');
|
||||
my $url = Mojo::URL->new('/app/login');
|
||||
$url->query( redirect_to => $c->url_for );
|
||||
$c->redirect_to($url);
|
||||
return 0;
|
||||
};
|
||||
|
||||
if ( $c->url_for->path =~ /^\/login\/?$/ ) {
|
||||
if ( $c->url_for->path =~ /^\/app\/login\/?$/ ) {
|
||||
return 1;
|
||||
}
|
||||
if ( !defined $c->session->{user} ) {
|
||||
|
@ -43,7 +43,7 @@ sub login_post($self) {
|
||||
return $self->_invalid_login;
|
||||
}
|
||||
$self->session->{user} = $username;
|
||||
return $self->redirect_to('/');
|
||||
return $self->redirect_to('/app');
|
||||
}
|
||||
|
||||
sub _invalid_login($self) {
|
||||
@ -80,7 +80,7 @@ sub create_vpn_user_post($self) {
|
||||
$new_user->insert;
|
||||
$new_user = $new_user->get_from_storage;
|
||||
my $id = $new_user->id;
|
||||
my $url = Mojo::URL->new("/vpn/user/$id/details");
|
||||
my $url = Mojo::URL->new("/app/vpn/user/$id/details");
|
||||
return $self->redirect_to($url);
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ sub enable_user($self) {
|
||||
);
|
||||
}
|
||||
$user->update( { is_enabled => 1 } );
|
||||
return $self->redirect_to('/');
|
||||
return $self->redirect_to('/app');
|
||||
}
|
||||
|
||||
sub disable_user($self) {
|
||||
@ -165,7 +165,7 @@ sub disable_user($self) {
|
||||
return $self->render( text => 'This user is protected', status => 400 )
|
||||
if $user->is_protected;
|
||||
$user->update( { is_enabled => 0 } );
|
||||
return $self->redirect_to('/');
|
||||
return $self->redirect_to('/app');
|
||||
}
|
||||
|
||||
sub whitelist_add($self) {
|
||||
@ -177,11 +177,11 @@ sub whitelist_add($self) {
|
||||
if ($@) {
|
||||
warn $@;
|
||||
}
|
||||
return $self->redirect_to('/');
|
||||
return $self->redirect_to('/app');
|
||||
}
|
||||
sub whitelist_remove($self) {
|
||||
my $resultset = VPNManager::Schema->Schema->resultset('WhitelistConsole');
|
||||
my $id = $self->param('id');
|
||||
$resultset->search({id => $id})->delete;
|
||||
return $self->redirect_to('/');
|
||||
return $self->redirect_to('/app');
|
||||
}1;
|
||||
|
@ -6,12 +6,12 @@
|
||||
</head>
|
||||
<body class="main">
|
||||
<h2>VPN Users</h2>
|
||||
<p><a href="/vpn/create-user">Create new vpn user</a>.</p>
|
||||
<p><a href="/app/vpn/create-user">Create new vpn user</a>.</p>
|
||||
% if (defined $users && @$users) {
|
||||
<ul>
|
||||
% for my $user (@$users) {
|
||||
<li>Id: <b><%=$user->id%></b> Name: <b><%=decode 'utf-8', $user->name%></b> Internal IP Address: <b><%=$user->ip_to_text%></b> <a href="/vpn/user/<%=$user->id%>/details">View details</a>
|
||||
<form class="inline" method="post" action="/vpn/user/<%=$user->id%>/<%=$user->is_enabled ? 'disable' : 'enable'%>">
|
||||
<li>Id: <b><%=$user->id%></b> Name: <b><%=decode 'utf-8', $user->name%></b> Internal IP Address: <b><%=$user->ip_to_text%></b> <a href="/app/vpn/user/<%=$user->id%>/details">View details</a>
|
||||
<form class="inline" method="post" action="/app/vpn/user/<%=$user->id%>/<%=$user->is_enabled ? 'disable' : 'enable'%>">
|
||||
<input type="submit" value="<%=$user->is_enabled? 'Disable' : 'Enable'%>"/>
|
||||
</form></li>
|
||||
% }
|
||||
|
@ -3,7 +3,7 @@
|
||||
<link rel="stylesheet" href="/style.css"/>
|
||||
</head>
|
||||
<body class="login-body">
|
||||
<form class="login-form" action="/login" method="post">
|
||||
<form class="login-form" action="/app/login" method="post">
|
||||
<div class="login-field">
|
||||
<label for="username">Username</label>
|
||||
<input name="username" type="text"/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<link rel="stylesheet" href="/style.css"/>
|
||||
</head>
|
||||
<body class="create-user">
|
||||
<form action="/vpn/create-user" method="post">
|
||||
<form action="/app/vpn/create-user" method="post">
|
||||
<div>
|
||||
<label for="name">Name</label>
|
||||
<input name="name"/>
|
||||
|
@ -5,6 +5,6 @@
|
||||
<link rel="stylesheet" href="/style.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/vpn/user/<%=$user->id%>/download" download="wg0.conf">Dowload vpn file</a>
|
||||
<a href="/app/vpn/user/<%=$user->id%>/download" download="wg0.conf">Dowload vpn file</a>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<h1>VPN Account</h1>
|
||||
<h2>Name: <%=decode 'utf-8', $user->name%></h2>
|
||||
<h2>Internal IP Address: <%=$user->ip_to_text%></h2>
|
||||
<form action="/vpn/user/<%=$user->id%>/download" target="_blank" method="post">
|
||||
<form action="/app/vpn/user/<%=$user->id%>/download" target="_blank" method="post">
|
||||
<input type="submit" value="Download new VPN file"/>
|
||||
</form>
|
||||
<p><a href="/">Volver al menu principal</a></p>
|
||||
|
Loading…
Reference in New Issue
Block a user