finished WIP Mail REST API: regular user UI for application passwords

This commit is contained in:
ralf 2023-07-11 22:46:37 +02:00
parent c63784d7e8
commit 53022a39b4
3 changed files with 17 additions and 6 deletions

View File

@ -76,7 +76,7 @@ class Token
!(new Api\Auth())->authenticate($GLOBALS['egw_info']['user']['account_lid'], $content['password'])) !(new Api\Auth())->authenticate($GLOBALS['egw_info']['user']['account_lid'], $content['password']))
{ {
Api\Etemplate::set_validation_error('password', lang('Password is invalid')); Api\Etemplate::set_validation_error('password', lang('Password is invalid'));
unset($content['button']); $button = null;
} }
try { try {
switch($button) switch($button)
@ -127,6 +127,7 @@ class Token
'button[delete]' => !$content['token_id'], 'button[delete]' => !$content['token_id'],
'account_id' => empty($GLOBALS['egw_info']['user']['apps']['admin']) || static::APP !== 'admin', 'account_id' => empty($GLOBALS['egw_info']['user']['apps']['admin']) || static::APP !== 'admin',
]; ];
$GLOBALS['egw_info']['flags']['app_header'] = empty($content['token_id']) ? lang('Add token') : lang('Edit token');
$tmpl = new Api\Etemplate(self::APP.'.token.edit'); $tmpl = new Api\Etemplate(self::APP.'.token.edit');
$tmpl->exec(static::APP.'.'.static::class.'.edit', $content, [], $readonlys, $content, 2); $tmpl->exec(static::APP.'.'.static::class.'.edit', $content, [], $readonlys, $content, 2);
} }
@ -191,7 +192,7 @@ class Token
elseif(!empty($content['token']['action'])) elseif(!empty($content['token']['action']))
{ {
try { try {
Api\Framework::message($this->action($content['token']['action'], Api\Framework::message(self::action($content['token']['action'],
$content['token']['selected'], $content['token']['select_all'])); $content['token']['selected'], $content['token']['select_all']));
} }
catch (\Exception $ex) { catch (\Exception $ex) {
@ -285,7 +286,7 @@ class Token
* @returns string with success message * @returns string with success message
* @throws Api\Exception\AssertionFailed * @throws Api\Exception\AssertionFailed
*/ */
protected function action($action, $selected, $select_all) protected static function action($action, $selected, $select_all=false)
{ {
$success = 0; $success = 0;
try { try {

View File

@ -5,7 +5,7 @@
<grid width="100%" height="100%"> <grid width="100%" height="100%">
<columns> <columns>
<column width="30"/> <column width="30"/>
<column width="120"/> <!-- User / All user --> <column width="120" disabled="@no_account_id"/> <!-- User / All user -->
<column width="25%"/> <!-- Applications --> <column width="25%"/> <!-- Applications -->
<column width="120"/> <!-- Expiration --> <column width="120"/> <!-- Expiration -->
<column width="120"/> <!-- Revoked / By --> <column width="120"/> <!-- Revoked / By -->

View File

@ -42,16 +42,26 @@ class Token extends Admin\Token
'prepend' => false, 'prepend' => false,
'data' => [ 'data' => [
'token' => [ 'token' => [
'default_cols' => '!account_id',
'add_action' => 'app.preferences.addToken', 'add_action' => 'app.preferences.addToken',
'no_account_id' => true,
]+self::get_nm_options(), ]+self::get_nm_options(),
], ],
'preserve' => [ 'preserve' => [
], ],
'sel_options' => [ 'sel_options' => [
], ],
'save_callback' => __CLASS__.'::action', 'save_callback' => __CLASS__.'::save_callback',
]; ];
} }
public static function save_callback(array &$content)
{
Api\Translation::add_app('admin');
try {
Api\Framework::message(self::action($content['token']['action'], $content['token']['selected']), 'success');
}
catch (\Exception $e) {
Api\Framework::message($e->getMessage(), 'error');
}
}
} }