Browse Source
Move the Admin page within Movim and simply use the default XMPP authentication system
Move the Admin page within Movim and simply use the default XMPP authentication system
Cleanup old widgets and files Update the MaterialIcons font Add a setAdmin command to set some users adminspull/992/head
25 changed files with 146 additions and 433 deletions
-
13app/controllers/AdminController.php
-
26app/controllers/AdminloginController.php
-
38app/views/admin.tpl
-
19app/views/adminlogin.tpl
-
10app/widgets/AdminLogin/AdminLogin.php
-
22app/widgets/AdminLogin/adminlogin.tpl
-
11app/widgets/AdminMain/AdminMain.php
-
26app/widgets/AdminMain/adminmain.tpl
-
2app/widgets/AdminSessions/AdminSessions.php
-
12app/widgets/AdminSessions/adminsessions.tpl
-
3app/widgets/AdminSessions/locales.ini
-
28app/widgets/AdminTest/AdminTest.php
-
112app/widgets/AdminTest/admintest.css
-
49app/widgets/AdminTest/admintest.js
-
84app/widgets/AdminTest/admintest.tpl
-
14app/widgets/AdminTest/locales.ini
-
16app/widgets/Navigation/navigation.tpl
-
16daemon.php
-
2database/migrations/20210420201638_add_origin_id_index_to_messages_table.php
-
34database/migrations/20210510204138_add_admin_column_to_users_table.php
-
2public/scripts/movim_websocket.js
-
1public/theme/fonts/MaterialIcons/MaterialIcons-Regular.ijmap
-
BINpublic/theme/fonts/MaterialIcons/MaterialIconsRegular.woff2
-
38src/Movim/Console/SetAdmin.php
-
1src/Movim/Route.php
@ -1,26 +0,0 @@ |
|||
<?php |
|||
|
|||
use Movim\Controller\Base; |
|||
use App\Configuration; |
|||
|
|||
class AdminloginController extends Base |
|||
{ |
|||
public function dispatch() |
|||
{ |
|||
$this->page->setTitle(__('page.administration')); |
|||
session_start(); |
|||
|
|||
$configuration = Configuration::findOrNew(1); |
|||
|
|||
if (isset($_POST['username']) |
|||
&& $configuration->username == $_POST['username'] |
|||
&& (password_verify($_POST['password'], $configuration->password) |
|||
|| $configuration->password == sha1($_POST['password']))) { |
|||
$_SESSION['admin'] = true; |
|||
} |
|||
|
|||
if (isset($_SESSION['admin']) && $_SESSION['admin'] == true) { |
|||
$this->redirect('admin'); |
|||
} |
|||
} |
|||
} |
|||
@ -1,24 +1,38 @@ |
|||
<?php $this->widget('Search');?> |
|||
<?php $this->widget('VisioLink');?> |
|||
<?php $this->widget('Notification');?> |
|||
<?php $this->widget('Toast');?> |
|||
<?php $this->widget('Onboarding');?> |
|||
<?php $this->widget('Notifications');?> |
|||
|
|||
<nav class="color dark"> |
|||
<?php $this->widget('Presence');?> |
|||
<?php $this->widget('Navigation');?> |
|||
</nav> |
|||
|
|||
<?php $this->widget('BottomNavigation');?> |
|||
|
|||
<main> |
|||
<div> |
|||
<header> |
|||
<header class="on_desktop"> |
|||
<ul class="list middle"> |
|||
<li> |
|||
<span class="primary active icon gray"> |
|||
<a href="<?php echo \Movim\Route::urlize('main'); ?>"> |
|||
<i class="material-icons">arrow_back</i> |
|||
</a> |
|||
<span id="menu" class="primary icon gray" > |
|||
<i class="material-icons">manage_accounts</i> |
|||
</span> |
|||
<div> |
|||
<p class="center"><?php echo __('page.administration'); ?></p> |
|||
<p><?php echo __('page.administration'); ?></p> |
|||
</div> |
|||
</li> |
|||
</ul> |
|||
</header> |
|||
<?php $this->widget('Tabs');?> |
|||
<ul class="tabs" id="navtabs"></ul> |
|||
<?php $this->widget('AdminTest');?> |
|||
<?php $this->widget('AdminMain');?> |
|||
<?php $this->widget('AdminSessions');?> |
|||
<?php $this->widget('Api');?> |
|||
|
|||
<?php if (\App\User::me()->admin) { ?> |
|||
<?php $this->widget('Tabs');?> |
|||
<ul class="tabs" id="navtabs"></ul> |
|||
|
|||
<?php $this->widget('AdminMain');?> |
|||
<?php $this->widget('AdminSessions');?> |
|||
<?php } ?> |
|||
</div> |
|||
</main> |
|||
@ -1,19 +0,0 @@ |
|||
<main> |
|||
<div> |
|||
<header> |
|||
<ul class="list middle"> |
|||
<li> |
|||
<span class="primary active icon gray"> |
|||
<a href="<?php echo \Movim\Route::urlize('main'); ?>"> |
|||
<i class="material-icons">arrow_back</i> |
|||
</a> |
|||
</span> |
|||
<div> |
|||
<p class="center"><?php echo __('page.administration'); ?></p> |
|||
</div> |
|||
</li> |
|||
</ul> |
|||
</header> |
|||
<?php $this->widget('AdminLogin');?> |
|||
</div> |
|||
</main> |
|||
@ -1,10 +0,0 @@ |
|||
<?php |
|||
|
|||
use Movim\Widget\Base; |
|||
|
|||
class AdminLogin extends Base |
|||
{ |
|||
public function load() |
|||
{ |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
<div> |
|||
<ul class="list thick"> |
|||
<li> |
|||
<form method="post"> |
|||
<div> |
|||
<input type="text" name="username" class="content" placeholder="{$c->__('input.username')}"> |
|||
<label for="username">{$c->__('input.username')}</label> |
|||
</div> |
|||
<div> |
|||
<input type="password" name="password" class="content" placeholder="{$c->__('input.password')}"> |
|||
<label for="password">{$c->__('input.password')}</label> |
|||
</div> |
|||
|
|||
<input |
|||
class="button oppose color" |
|||
type="submit" |
|||
name="submit" |
|||
value="{$c->__('button.validate')}" /> |
|||
</form> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
@ -1,2 +1,3 @@ |
|||
[adminsessions] |
|||
title = Sessions |
|||
title = Sessions |
|||
text = Currently connected users on the pod |
|||
@ -1,28 +0,0 @@ |
|||
<?php |
|||
|
|||
use Movim\Widget\Base; |
|||
|
|||
class AdminTest extends Base |
|||
{ |
|||
public function load() |
|||
{ |
|||
$this->addjs('admintest.js'); |
|||
$this->addcss('admintest.css'); |
|||
} |
|||
|
|||
public function testDir($dir) |
|||
{ |
|||
return (file_exists($dir) && is_dir($dir) && is_writable($dir)); |
|||
} |
|||
|
|||
public function testFile($file) |
|||
{ |
|||
return (file_exists($file) && is_writable($file)); |
|||
} |
|||
|
|||
public function display() |
|||
{ |
|||
// Check with Eloquent or delete
|
|||
$this->view->assign('dbconnected', true); |
|||
} |
|||
} |
|||
@ -1,112 +0,0 @@ |
|||
figure { |
|||
width: 100%; |
|||
height: 40em; |
|||
position: relative; |
|||
font-size: 1.5rem; |
|||
} |
|||
|
|||
figure div { |
|||
display: block; |
|||
width: 20%; |
|||
margin-top: -2.5em; |
|||
margin-left: -10%; |
|||
background-color: var(--movim-background); |
|||
border-radius: 0.2em; |
|||
text-align: center; |
|||
position: absolute; |
|||
line-height: 5em; |
|||
font-weight: bold; |
|||
white-space: nowrap; |
|||
text-overflow: ellipsis; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
figure div#webserver { |
|||
width: 50%; |
|||
height: 30em; |
|||
border: 0.5em solid gray; |
|||
width: 26%; |
|||
border-radius: 0.2em; |
|||
height: 22em; |
|||
border: 0.5em dashed var(--movim-background); |
|||
left: 46%; |
|||
background-color: transparent; |
|||
top: 10%; |
|||
} |
|||
|
|||
figure div#movim_block { left: 50%; top: 50%; } |
|||
figure div#database_block { left: 50%; top: 85%; } |
|||
figure div#xmpp_block { left: 85%; top: 15%; } |
|||
figure div#browser_block { left: 15%; top: 15%; line-height: 19em; } |
|||
figure div#daemon_block { left: 50%; top: 15%; } |
|||
figure div#api_block { left: 85%; top: 50%; } |
|||
|
|||
figure div.link { |
|||
width: 0; |
|||
height: 0; |
|||
padding: 0.25em; |
|||
line-height: 1rem; |
|||
overflow: initial; |
|||
} |
|||
|
|||
figure div.link i { |
|||
background-color: var(--movim-background); |
|||
margin-top: -2rem; |
|||
padding: 1.5rem 1rem; |
|||
border-radius: 6rem; |
|||
font-size: 3rem; |
|||
} |
|||
|
|||
figure div.disabled { background-color: rgba(0, 0, 0, 0.1); color: white;} |
|||
figure div.success { background-color: #6FCC43; color: white; } |
|||
figure div.warning { background-color: #FC8F12; color: white; } |
|||
figure div.error { background-color: #D92727; color: white; } |
|||
|
|||
figure div.link.disabled { color: #CCC; } |
|||
figure div.link.success { color: #6FCC43; } |
|||
figure div.link.warning { color: #FC8F12; } |
|||
figure div.link.error { color: #D92727; } |
|||
|
|||
figure div.link.horizontal { |
|||
width: 35%; |
|||
} |
|||
|
|||
figure div.link.vertical { |
|||
height: 35%; |
|||
} |
|||
|
|||
figure div.link.vertical i { |
|||
top: 50%; |
|||
position: absolute; |
|||
margin-left: -0.75em; |
|||
} |
|||
|
|||
figure div.link#movim-daemon { |
|||
left: 60%; |
|||
top: 20%; |
|||
} |
|||
|
|||
figure div.link#movim-database { |
|||
left: 60%; |
|||
top: 55%; |
|||
} |
|||
|
|||
figure div.link#movim-browser { |
|||
left: 25%; |
|||
top: 55%; |
|||
} |
|||
|
|||
figure div.link#browser-daemon { |
|||
left: 25%; |
|||
top: 20%; |
|||
} |
|||
|
|||
figure div.link#xmpp-daemon { |
|||
left: 60%; |
|||
top: 20%; |
|||
} |
|||
|
|||
figure div.link#movim-api { |
|||
left: 60%; |
|||
top: 55%; |
|||
} |
|||
@ -1,49 +0,0 @@ |
|||
var AdminTest = { |
|||
databaseOK : false, |
|||
websocketOK : false, |
|||
apiOK : false, |
|||
movimOK : true, |
|||
|
|||
toggleConfiguration : function() { |
|||
if (this.databaseOK && this.websocketOK && this.movimOK) { |
|||
MovimUtils.removeClass('li.admingen', 'disabled'); |
|||
MovimUtils.removeClass('li.api', 'disabled'); |
|||
} else { |
|||
MovimUtils.addClass('li.admingen', 'disabled'); |
|||
MovimUtils.addClass('li.api', 'disabled'); |
|||
} |
|||
}, |
|||
|
|||
enableWebsocket : function() { |
|||
this.websocketOK = true; |
|||
this.toggleConfiguration(); |
|||
|
|||
MovimUtils.removeClass('figure #browser-daemon', 'error'); |
|||
MovimUtils.addClass('figure #browser-daemon', 'success'); |
|||
MovimUtils.addClass('div #xmpp-daemon', 'success'); |
|||
|
|||
document.querySelector('#websocket_error').classList.add('hide'); |
|||
}, |
|||
|
|||
enableAPI : function() { |
|||
this.apiOK = true; |
|||
|
|||
MovimUtils.removeClass('figure #movim-api', 'disabled'); |
|||
MovimUtils.addClass('figure #movim-api', 'success'); |
|||
}, |
|||
|
|||
disableMovim : function() { |
|||
this.movimOK = false; |
|||
|
|||
MovimUtils.addClass('figure #movim_block', 'error'); |
|||
} |
|||
}; |
|||
|
|||
MovimWebsocket.attach(function() { |
|||
AdminTest.enableWebsocket(); |
|||
AdminTest.toggleConfiguration(); |
|||
}); |
|||
|
|||
movimAddOnload(function() { |
|||
AdminTest.toggleConfiguration(); |
|||
}); |
|||
@ -1,84 +0,0 @@ |
|||
<div id="admincomp" class="tabelem" title="{$c->__('admin.compatibility')}"> |
|||
<div> |
|||
<figure> |
|||
<div id="webserver"></div> |
|||
<div id="movim-daemon" class="link vertical disabled"><i class="material-icons">settings</i></div> |
|||
<div id="movim-browser" class="link horizontal success"><i class="material-icons">open_in_browser</i></div> |
|||
<div id="browser-daemon" class="link horizontal error"><i class="material-icons">code</i></div> |
|||
<div id="xmpp-daemon" class="link horizontal"><i class="material-icons">import_export</i></div> |
|||
<div id="movim-database" class="link vertical {if="$dbconnected"}success{else}error{/if}"> |
|||
<i class="material-icons">swap_horiz</i> |
|||
</div> |
|||
<div id="movim-api" class="link horizontal disabled"><i class="material-icons">cloud</i></div> |
|||
<div id="browser_block"> |
|||
{$c->__('schema.browser')} |
|||
</div> |
|||
<div id="movim_block"> |
|||
{$c->__('schema.movim')} |
|||
</div> |
|||
<div id="daemon_block"> |
|||
{$c->__('schema.daemon')} |
|||
</div> |
|||
<div id="database_block" class="{if="$dbconnected"}success{else}error{/if}"> |
|||
{$c->__('schema.database')} |
|||
</div> |
|||
<div id="api_block"> |
|||
{$c->__('schema.api')} |
|||
</div> |
|||
<div id="xmpp_block"> |
|||
{$c->__('schema.xmpp')} |
|||
</div> |
|||
</figure> |
|||
</div> |
|||
|
|||
<ul class="list"> |
|||
{if="$dbconnected"} |
|||
<script type="text/javascript">AdminTest.databaseOK = true</script> |
|||
{else} |
|||
<li> |
|||
<span class="primary icon bubble color red"> |
|||
<i class="material-icons">data_usage</i> |
|||
</span> |
|||
<div> |
|||
<p>Database connection error</p> |
|||
<p>Check if database configuration exist in the <code>config/</code> folder and fill it with proper values</p> |
|||
</div> |
|||
</li> |
|||
{/if} |
|||
|
|||
<li id="websocket_error"> |
|||
<span class="primary icon bubble color red"> |
|||
<i class="material-icons">code</i> |
|||
</span> |
|||
<div> |
|||
<p class="normal line"> |
|||
{$c->__('compatibility.websocket')} |
|||
</p> |
|||
</div> |
|||
</li> |
|||
|
|||
{if="!$c->testDir(CACHE_PATH)"} |
|||
<li> |
|||
<span class="primary icon color bubble red"> |
|||
<i class="material-icons">folder</i> |
|||
</span> |
|||
<div> |
|||
<p class="normal line">{$c->__('compatibility.rights', 'cache')}</p> |
|||
</div> |
|||
</li> |
|||
<script type="text/javascript">AdminTest.disableMovim()</script> |
|||
{/if} |
|||
|
|||
{if="!$c->testDir(LOG_PATH)"} |
|||
<li> |
|||
<span class="primary icon color bubble red"> |
|||
<i class="material-icons">folder</i> |
|||
</span> |
|||
<div> |
|||
<p class="normal line">{$c->__('compatibility.rights', 'log')}</p> |
|||
</div> |
|||
</li> |
|||
<script type="text/javascript">AdminTest.disableMovim()</script> |
|||
{/if} |
|||
</ul> |
|||
</div> |
|||
@ -1,14 +0,0 @@ |
|||
[admin] |
|||
compatibility = General Overview |
|||
|
|||
[compatibility] |
|||
rights = "Read and write rights for the webserver in Movim’s %s directory" |
|||
websocket = WebSocket connection error, check if the Movim Daemon is running and is reachable |
|||
|
|||
[schema] |
|||
browser = Browser |
|||
movim = Movim Core |
|||
daemon = Movim Daemon |
|||
database = Database |
|||
api = API |
|||
xmpp = XMPP |
|||
@ -0,0 +1,34 @@ |
|||
<?php |
|||
|
|||
use Movim\Migration; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
|
|||
class AddAdminColumnToUsersTable extends Migration |
|||
{ |
|||
public function up() |
|||
{ |
|||
$this->schema->table('users', function (Blueprint $table) { |
|||
$table->boolean('admin')->default('false'); |
|||
$table->index('admin'); |
|||
}); |
|||
|
|||
$this->schema->table('configuration', function (Blueprint $table) { |
|||
$table->string('banner')->nullable(); |
|||
$table->dropColumn('username'); |
|||
$table->dropColumn('password'); |
|||
}); |
|||
} |
|||
|
|||
public function down() |
|||
{ |
|||
$this->schema->table('users', function (Blueprint $table) { |
|||
$table->dropColumn('admin'); |
|||
}); |
|||
|
|||
$this->schema->table('configuration', function (Blueprint $table) { |
|||
$table->dropColumn('banner'); |
|||
$table->string('username')->nullable(); |
|||
$table->string('password')->nullable(); |
|||
}); |
|||
} |
|||
} |
|||
1
public/theme/fonts/MaterialIcons/MaterialIcons-Regular.ijmap
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,38 @@ |
|||
<?php |
|||
|
|||
namespace Movim\Console; |
|||
|
|||
use Symfony\Component\Console\Command\Command; |
|||
use Symfony\Component\Console\Input\InputInterface; |
|||
use Symfony\Component\Console\Input\InputArgument; |
|||
use Symfony\Component\Console\Output\OutputInterface; |
|||
|
|||
use App\User; |
|||
|
|||
class SetAdmin extends Command |
|||
{ |
|||
protected function configure() |
|||
{ |
|||
$this |
|||
->setName('setAdmin') |
|||
->setDescription('Set an account admin') |
|||
->addArgument('jid', InputArgument::REQUIRED, 'User Jabber ID'); |
|||
} |
|||
|
|||
protected function execute(InputInterface $input, OutputInterface $output) |
|||
{ |
|||
$user = User::find($input->getArgument('jid')); |
|||
|
|||
if ($user) { |
|||
$user->admin = true; |
|||
$user->save(); |
|||
$output->writeln('<info>User '.$input->getArgument('jid').' is now admin</info>'); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
$output->writeln('<error>User '.$input->getArgument('jid').' not found</error>'); |
|||
|
|||
return 1; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue