Add temporary passwords
This commit is contained in:
parent
871dfa5675
commit
ccc686ae28
9 changed files with 204 additions and 5 deletions
|
@ -89,6 +89,10 @@ class ACL extends \Zend\Permissions\Acl\Acl
|
||||||
|
|
||||||
'/complains/{sid}',
|
'/complains/{sid}',
|
||||||
'/complains/delete/{sid}/{tcldbid}',
|
'/complains/delete/{sid}/{tcldbid}',
|
||||||
|
|
||||||
|
'/passwords/{sid}',
|
||||||
|
'/passwords/add/{sid}',
|
||||||
|
'/passwords/delete/{sid}',
|
||||||
];
|
];
|
||||||
|
|
||||||
const ACL_DEFAULT_ALLOWS = [
|
const ACL_DEFAULT_ALLOWS = [
|
||||||
|
|
|
@ -326,3 +326,19 @@ $container[SnapshotDeleteAction::class] = function ($container) {
|
||||||
return new SnapshotDeleteAction($container);
|
return new SnapshotDeleteAction($container);
|
||||||
};
|
};
|
||||||
$app->get('/snapshots/delete/{sid}/{name}', SnapshotDeleteAction::class);
|
$app->get('/snapshots/delete/{sid}/{name}', SnapshotDeleteAction::class);
|
||||||
|
|
||||||
|
// passwords
|
||||||
|
$container[PasswordsAction::class] = function ($container) {
|
||||||
|
return new PasswordsAction($container);
|
||||||
|
};
|
||||||
|
$app->get('/passwords/{sid}', PasswordsAction::class);
|
||||||
|
|
||||||
|
$container[PasswordAddAction::class] = function ($container) {
|
||||||
|
return new PasswordAddAction($container);
|
||||||
|
};
|
||||||
|
$app->post('/passwords/add/{sid}', PasswordAddAction::class);
|
||||||
|
|
||||||
|
$container[PasswordDeleteAction::class] = function ($container) {
|
||||||
|
return new PasswordDeleteAction($container);
|
||||||
|
};
|
||||||
|
$app->post('/passwords/delete/{sid}', PasswordDeleteAction::class);
|
||||||
|
|
|
@ -63,6 +63,7 @@ menu.servers.clients: "Clients"
|
||||||
menu.servers.groups: "Groups"
|
menu.servers.groups: "Groups"
|
||||||
menu.servers.bans: "Bans"
|
menu.servers.bans: "Bans"
|
||||||
menu.servers.complains: "Complains"
|
menu.servers.complains: "Complains"
|
||||||
|
menu.servers.passwords: "Passwords"
|
||||||
menu.servers.tokens: "Tokens"
|
menu.servers.tokens: "Tokens"
|
||||||
menu.servers.snapshots: "Snapshots"
|
menu.servers.snapshots: "Snapshots"
|
||||||
menu.servers.logs: "Log"
|
menu.servers.logs: "Log"
|
||||||
|
@ -86,6 +87,7 @@ channelgroup_info.title: "Channelgroup"
|
||||||
profile.title: "Profile"
|
profile.title: "Profile"
|
||||||
tokens.title: "Tokens"
|
tokens.title: "Tokens"
|
||||||
snapshots.title: "Snapshots"
|
snapshots.title: "Snapshots"
|
||||||
|
passwords.title: "Passwords"
|
||||||
|
|
||||||
# dynamic render of key value pairs
|
# dynamic render of key value pairs
|
||||||
key: "Attribute"
|
key: "Attribute"
|
||||||
|
@ -244,3 +246,12 @@ snapshots.h.details: "Details"
|
||||||
snapshots.deploy: "Deploy"
|
snapshots.deploy: "Deploy"
|
||||||
snapshots.delete: "Delete"
|
snapshots.delete: "Delete"
|
||||||
|
|
||||||
|
# passwords
|
||||||
|
passwords.h.actions: "Actions"
|
||||||
|
passwords.h.details: "Details"
|
||||||
|
passwords.add: "Add a temporary password"
|
||||||
|
passwords.add.password: "Password"
|
||||||
|
passwords.add.duration: "Duration (in seconds)"
|
||||||
|
passwords.add.description: "Description"
|
||||||
|
passwords.add.channel: "Channel (user joins)"
|
||||||
|
passwords.add.channel_password: "Channelpassword"
|
34
src/Control/Actions/PasswordAddAction.php
Normal file
34
src/Control/Actions/PasswordAddAction.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Slim\Http\Request;
|
||||||
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
final class PasswordAddAction extends AbstractAction
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request, Response $response, $args)
|
||||||
|
{
|
||||||
|
$sid = $args['sid'];
|
||||||
|
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$password = $body['password'];
|
||||||
|
$duration = $body['duration'];
|
||||||
|
$description = $body['description'];
|
||||||
|
$channel = $body['channel'];
|
||||||
|
$channelPassword = $body['channel_password'];
|
||||||
|
|
||||||
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
|
|
||||||
|
$passwordAddResult = $this->ts->getInstance()->serverTempPasswordAdd(
|
||||||
|
$password,
|
||||||
|
$duration,
|
||||||
|
$description,
|
||||||
|
$channel,
|
||||||
|
$channelPassword
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
return $response->withRedirect('/passwords/' . $sid);
|
||||||
|
}
|
||||||
|
}
|
23
src/Control/Actions/PasswordDeleteAction.php
Normal file
23
src/Control/Actions/PasswordDeleteAction.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Slim\Http\Request;
|
||||||
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
final class PasswordDeleteAction extends AbstractAction
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request, Response $response, $args)
|
||||||
|
{
|
||||||
|
$sid = $args['sid'];
|
||||||
|
$body = $request->getParsedBody();
|
||||||
|
$password = $body['pw_clear'];
|
||||||
|
|
||||||
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
|
|
||||||
|
$passwordDeleteResult = $this->ts->getInstance()->serverTempPasswordDel($password);
|
||||||
|
|
||||||
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
return $response->withRedirect('/passwords/' . $sid);
|
||||||
|
}
|
||||||
|
}
|
33
src/Control/Actions/PasswordsAction.php
Normal file
33
src/Control/Actions/PasswordsAction.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Slim\Http\Request;
|
||||||
|
use Slim\Http\Response;
|
||||||
|
|
||||||
|
final class PasswordsAction extends AbstractAction
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request, Response $response, $args)
|
||||||
|
{
|
||||||
|
$sid = $args['sid'];
|
||||||
|
|
||||||
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
|
|
||||||
|
$dataResult = $this->ts->getInstance()->serverTempPasswordList();
|
||||||
|
$channelsResult = $this->ts->getInstance()->channelList();
|
||||||
|
$channelsResult = $this->ts->getInstance()->getElement('data', $channelsResult);
|
||||||
|
$channels = [];
|
||||||
|
$channels['---'] = 0;
|
||||||
|
|
||||||
|
foreach ($channelsResult as $channel) {
|
||||||
|
$channels[$channel['channel_name']] = $channel['cid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// render GET
|
||||||
|
$this->view->render($response, 'passwords.twig', [
|
||||||
|
'title' => $this->translator->trans('passwords.title'),
|
||||||
|
'data' => $this->ts->getInstance()->getElement('data', $dataResult),
|
||||||
|
'channels' => $channels,
|
||||||
|
'sid' => $sid
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,17 +14,42 @@
|
||||||
|
|
||||||
{% if item %}
|
{% if item %}
|
||||||
<input type="hidden" name="{{ editable.key }}"
|
<input type="hidden" name="{{ editable.key }}"
|
||||||
id="{{ editable.key }}" value="0"/>
|
id="{{ editable.key }}" value="0"
|
||||||
|
|
||||||
|
{% if editable.readOnly is defined and editable.readOnly == true %}
|
||||||
|
readonly
|
||||||
|
{% endif %}
|
||||||
|
/>
|
||||||
<input type="checkbox" name="{{ editable.key }}"
|
<input type="checkbox" name="{{ editable.key }}"
|
||||||
id="{{ editable.key }}" value="1" checked/>
|
id="{{ editable.key }}" value="1" checked
|
||||||
|
|
||||||
|
{% if editable.readOnly is defined and editable.readOnly == true %}
|
||||||
|
readonly
|
||||||
|
{% endif %}
|
||||||
|
/>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="hidden" name="{{ editable.key }}"
|
<input type="hidden" name="{{ editable.key }}"
|
||||||
id="{{ editable.key }}" value="0" />
|
id="{{ editable.key }}" value="0"
|
||||||
|
|
||||||
|
{% if editable.readOnly is defined and editable.readOnly == true %}
|
||||||
|
readonly
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
/>
|
||||||
<input type="checkbox" name="{{ editable.key }}"
|
<input type="checkbox" name="{{ editable.key }}"
|
||||||
id="{{ editable.key }}" value="1" />
|
id="{{ editable.key }}" value="1"
|
||||||
|
|
||||||
|
{% if editable.readOnly is defined and editable.readOnly == true %}
|
||||||
|
readonly
|
||||||
|
{% endif %}
|
||||||
|
/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elseif editable.type == 'select' %}
|
{% elseif editable.type == 'select' %}
|
||||||
<select class="form-control" name="{{ editable.key }}" id="{{ editable.key }}">
|
<select class="form-control" name="{{ editable.key }}" id="{{ editable.key }}"
|
||||||
|
{% if editable.readOnly is defined and editable.readOnly == true %}
|
||||||
|
readonly
|
||||||
|
{% endif %}
|
||||||
|
>
|
||||||
|
|
||||||
{% for k,v in editable.options %}
|
{% for k,v in editable.options %}
|
||||||
{% if v == item %}
|
{% if v == item %}
|
||||||
|
@ -40,6 +65,9 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
value="{{ item }}"
|
value="{{ item }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if editable.readOnly is defined and editable.readOnly == true %}
|
||||||
|
readonly
|
||||||
|
{% endif %}
|
||||||
/>
|
/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
<a href="/complains/{{ session_get('sid') }}">
|
<a href="/complains/{{ session_get('sid') }}">
|
||||||
<li class="active withripple" data-target="#page">{% trans %}menu.servers.complains{% endtrans %}</li>
|
<li class="active withripple" data-target="#page">{% trans %}menu.servers.complains{% endtrans %}</li>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="/passwords/{{ session_get('sid') }}">
|
||||||
|
<li class="active withripple" data-target="#page">{% trans %}menu.servers.passwords{% endtrans %}</li>
|
||||||
|
</a>
|
||||||
<a href="/tokens/{{ session_get('sid') }}">
|
<a href="/tokens/{{ session_get('sid') }}">
|
||||||
<li class="active withripple" data-target="#page">{% trans %}menu.servers.tokens{% endtrans %}</li>
|
<li class="active withripple" data-target="#page">{% trans %}menu.servers.tokens{% endtrans %}</li>
|
||||||
</a>
|
</a>
|
||||||
|
|
47
src/View/material/passwords.twig
Normal file
47
src/View/material/passwords.twig
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1 class="header">{{ title }}</h1>
|
||||||
|
|
||||||
|
<h2 class="header">{% trans %}passwords.h.actions{% endtrans %}</h2>
|
||||||
|
|
||||||
|
{% include 'form.twig' with {
|
||||||
|
'fields': [
|
||||||
|
{
|
||||||
|
'header_label': 'passwords.add'|trans,
|
||||||
|
'label': '<i class="material-icons">check_circle</i>',
|
||||||
|
'uri': '/passwords/add/' ~ sid,
|
||||||
|
'uri_method': 'post',
|
||||||
|
'fields': [
|
||||||
|
{'type': 'text', 'key': 'password', 'label': 'passwords.add.password'|trans},
|
||||||
|
{'type': 'number', 'key': 'duration', 'label': 'passwords.add.duration'|trans},
|
||||||
|
{'type': 'text', 'key': 'description', 'label': 'passwords.add.description'|trans},
|
||||||
|
{'type': 'select', 'key': 'channel', 'options': channels,'label': 'passwords.add.channel'|trans},
|
||||||
|
{'type': 'text', 'key': 'channel_password', 'label': 'passwords.add.channel_password'|trans},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
} %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if data|length > 0 %}
|
||||||
|
<h2 class="header">{% trans %}passwords.h.details{% endtrans %}</h2>
|
||||||
|
{% include 'table.twig' with {'data': data,
|
||||||
|
'hiddenColumns': ['uid', 'tcpw'],
|
||||||
|
'filters': [{'key': 'start', 'apply': 'timestamp'}, {'key': 'end', 'apply': 'timestamp'}],
|
||||||
|
'links': [
|
||||||
|
{'key': 'tcid', 'uri': '/channels/' ~ sid, 'uri_param': 'tcid'},
|
||||||
|
],
|
||||||
|
'attributesEditable': [
|
||||||
|
{
|
||||||
|
'key': 'pw_clear',
|
||||||
|
'type': 'text',
|
||||||
|
'uri': '/passwords/delete/' ~ sid,
|
||||||
|
'uri_method': 'post',
|
||||||
|
'submit_label': '<i class="material-icons">delete</i>',
|
||||||
|
'readOnly': true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
Reference in a new issue