Exemplo n.º 1
0
<?php

use Enpowi\Users\User;
$tf->test('Adding a user', function (\Testify\Testify $tf) {
    $email = '*****@*****.**';
    User::create($email, '123123123');
    $user = new User($email);
    $tf->assertTrue($user->bean() !== null);
});
$tf->test('Removing a user', function (\Testify\Testify $tf) {
    $email = '*****@*****.**';
    User::create($email, '123123123');
    (new User($email))->remove();
    $user = new User($email);
    $tf->assertTrue($user->bean() === null);
});
Exemplo n.º 2
0
<?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]);
Exemplo n.º 3
0
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);
//give registered abilities
Perm::create('gallery', '*', $registeredGroup);
Perm::create('user', 'view', $registeredGroup);
Perm::create('user', 'logout', $registeredGroup);
Perm::create('user', 'confirm', $registeredGroup);
Perm::create('page', 'edit', $registeredGroup);
//give Administrator group access to everything
Perm::create('*', '*', $administratorGroup);
//give everyone the ability to see modules with no security