<?php use Enpowi\App; use Enpowi\Users\User; use Enpowi\Modules\Module; Module::is(); $email = App::param('email'); $password = App::param('password'); $reply = []; $stop = false; if (!User::isEmailValid($email)) { $reply['email'] = 'Invalid'; $stop = true; } if (!User::isUnique($email)) { $reply['email'] = 'Already taken'; $stop = true; } if (!User::isValidPassword($password)) { $reply['password'] = '******'; $reply['repeatPassword'] = '******'; $stop = true; } if ($stop) { echo json_encode(['paramResponse' => $reply, 'id' => -1]); die; } $user = User::create($email, $password); echo json_encode(['id' => $user->id]);
<?php require_once 'setup/run.php'; use Enpowi\App; use Enpowi\Modules\Module; $moduleName = App::param('module') ?: App::param('m'); $componentName = App::param('component') ?: App::param('c'); $path = dirname(__FILE__); $component = App::loadComponent($path, $moduleName, $componentName); if ($component !== null && !empty($component->file)) { if ($component->isActive()) { Module::run(); $component->runInit(); require_once $component->file; $paramResponse = Module::getParamResponse(); if ($paramResponse !== null) { echo json_encode(['paramResponse' => $paramResponse]); } else { $successResponse = Module::getSuccessResponse(); if ($successResponse !== null) { echo json_encode(['successResponse' => $successResponse]); } } } else { require_once $component->file; } } else { if (!defined('testing')) { echo -1; } }
use Enpowi\App; use Enpowi\Users\User; use Enpowi\Modules\Module; Module::is(); $user = App::user(); $password = App::param('password'); $passwordRepeat = App::param('passwordRepeat'); $update = App::paramBool('update'); $stop = false; Module::paramRespond('password', ''); Module::paramRespond('passwordRepeat', ''); Module::paramRespond('passwordUpdated', ''); if (empty($password)) { $stop = true; } if (!$stop && $password !== $passwordRepeat) { Module::paramRespond('passwordRepeat', 'Passwords do not match'); $stop = true; } if (!$stop && !User::isValidPassword($password)) { Module::paramRespond('password', 'Invalid'); $stop = true; } if (!$stop) { if ($update) { if ($user->updatePassword($password)) { Module::paramRespond('passwordUpdated', 'Password updated'); } } }
<?php use Enpowi\Modules\DataOut; use Enpowi\Users\Group; use Enpowi\Modules\Module; Module::is(); $data = (new DataOut())->add('moduleMap', Module::map())->add('anonymousGroup', (new Group('Anonymous'))->updatePerms())->add('registeredGroup', (new Group('Registered'))->updatePerms())->add('editableGroups', Group::editableGroups(true, true))->out(); ?> <form v-module data="<?php echo $data; ?> " action="perms/listService" listen class="container"> <table class="table"> <thead> <tr> <th v-t colspan="2" class="center">Permission</th> <th v-t colspan="{{ editableGroups.length + 2 }}" class="center">Groups</th> </tr> <tr> <th v-t>Module</th> <th v-t>Component</th> <th class="center"> {{ anonymousGroup.name }} <input type="hidden" name="groupNames[]" value="{{ anonymousGroup.name }}"> </th>
<?php use Enpowi\Modules\Module; Module::is(); $perms = []; $groupNames = Enpowi\App::param('groupNames'); foreach ($groupNames as $groupName) { (new \Enpowi\Users\Group($groupName))->removePerms(); } foreach (Enpowi\App::param('perm') as $permUnparsed) { $parsed = Enpowi\Users\Perm::parse($permUnparsed); $group = new \Enpowi\Users\Group($parsed['group']); \Enpowi\Users\Perm::create($parsed['module'], $parsed['component'], $group); } Module::successRespond('success', true);
$passwordRepeat = App::param('passwordRepeat'); $update = App::paramBool('update'); $stopEmail = false; $stopPassword = false; if (empty($password)) { $stopPassword = true; } if (!$stopPassword && $password !== $passwordRepeat) { Module::paramRespond('passwordRepeat', 'Passwords do not match'); $stopPassword = true; } if (!$stopPassword && !User::isValidPassword($password)) { Module::paramRespond('password', 'Invalid'); $stopPassword = true; } if ($user->email !== $_user->email && !User::isEmailValid($_user->email)) { Module::paramRespond('email', 'Not a valid email'); $stopEmail = true; } if ($update) { if (!$stopEmail) { if ($user->email !== $_user->email && $user->updateEmail($_user->email)) { Module::successRespond('emailUpdated', 'Updated'); } } if (!$stopPassword) { if ($user->updatePassword($password)) { Module::successRespond('passwordUpdated', 'Password updated'); } } }
} if (!is_writable($dir)) { //throw new Exception('modules/setup folder needs write permission'); } if (!file_exists($dir . '/config.php')) { throw new Exception('You must first create modules/setup/config.php'); } require_once $dir . '/../../vendor/autoload.php'; require_once $dir . '/../setup/config.php'; use RedBeanPHP\R; use Enpowi\Users\Group; use Enpowi\Users\User; use Enpowi\Users\Perm; use Enpowi\App; use Enpowi\Modules\Module; Module::run(); R::nuke(); App::log('setup', 'newSite'); //create groups $everyoneGroup = Group::create('Everyone', false, false, true); $anonymousGroup = Group::create('Anonymous', false, true); $registeredGroup = Group::create('Registered', true); $administratorGroup = Group::create('Administrator', false, false, false, true); //create first user & put him in admin group $administratorUser = User::create('admin', 'admin', true); $administratorGroup->addUser($administratorUser); //give Anonymous abilities Perm::create('user', 'login', $anonymousGroup); Perm::create('user', 'register', $anonymousGroup); Perm::create('user', 'forgot', $anonymousGroup); Perm::create('user', 'confirm', $anonymousGroup);
<?php use Enpowi\App; use Enpowi\Modules\Module; use Enpowi\Files\Gallery; Module::is(); $name = App::param('name'); $description = App::param('description'); if (!Gallery::isUnique($name)) { Module::paramRespond('name', 'Not unique'); } else { $id = Gallery::create($name, $description); Module::successRespond('g', $id); }