protected function checkAccountStatus($response)
 {
     if ($this->site->auth) {
         $user = $this->site->auth;
         if (!(bool) $user->active) {
             \Savage\Http\Util\Session::delete($this->site->getContainer()->settings['auth']['session']);
             if (\Savage\Http\Util\Cookie::exists($this->site->getContainer()->settings['auth']['remember'])) {
                 $user->removeRememberCredentials();
                 \Savage\Http\Util\Cookie::delete($this->site->getContainer()->settings['auth']['remember']);
             }
             $this->site->getContainer()->flash->addMessage('error', 'Your account is banned.');
             return $response->withRedirect($this->site->getContainer()->router->pathFor('home'));
         }
     }
 }
Esempio n. 2
0
<?php

$site->route(['GET'], '/', \Savage\Http\Controllers\HomeController::class)->setName('home');
$site->route(['GET'], '/tests', \Savage\Http\Controllers\TestController::class, 'index')->setName('tests');
$site->route(['GET'], '/fakesomedata', \Savage\Http\Controllers\FakeController::class, 'index')->setName('fake.faker');
$site->get('/auth/logout', function ($request, $response, $args) use($site) {
    \Savage\Http\Util\Session::delete($site->getContainer()->settings['auth']['session']);
    if (\Savage\Http\Util\Cookie::exists($site->getContainer()->settings['auth']['remember'])) {
        $site->auth->removeRememberCredentials();
        \Savage\Http\Util\Cookie::delete($site->getContainer()->settings['auth']['remember']);
    }
    return $response->withRedirect($site->getContainer()->router->pathFor('home'));
})->setName('auth.logout');
$site->group('/auth', function () {
    $this->route(['GET', 'POST'], '/login', \Savage\Http\Controllers\AuthController::class, 'login')->add(new \Savage\Http\Filters\GuestFilter($this))->setName('auth.login');
    $this->route(['GET', 'POST'], '/register', \Savage\Http\Controllers\AuthController::class, 'register')->add(new \Savage\Http\Filters\GuestFilter($this))->setName('auth.register');
    $this->route(['GET'], '/settings', \Savage\Http\Controllers\AuthController::class, 'settings')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.settings');
    $this->route(['GET', 'POST'], '/settings/update/profile', \Savage\Http\Controllers\AuthController::class, 'profile')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.update.profile');
    $this->route(['GET', 'POST'], '/settings/update/password', \Savage\Http\Controllers\AuthController::class, 'password')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.update.password');
    $this->route(['GET'], '/notifications', \Savage\Http\Controllers\AuthController::class, 'notifications')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.notifications');
    $this->route(['GET'], '/messages', \Savage\Http\Controllers\AuthController::class, 'directMessages')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages');
    $this->route(['GET'], '/messages/sent', \Savage\Http\Controllers\AuthController::class, 'sentMessages')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.sent');
    $this->route(['GET'], '/messages/trash', \Savage\Http\Controllers\AuthController::class, 'trashedMessages')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.trash');
    $this->route(['GET', 'POST'], '/messages/view/{id}', Savage\Http\Controllers\AuthController::class, 'viewDirectMessage')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.view');
    $this->route(['POST'], '/messages/compose', Savage\Http\Controllers\AuthController::class, 'composeMessage')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.compose');
    $this->route(['POST'], '/messages/reply/{id}', Savage\Http\Controllers\AuthController::class, 'directMessageResponse')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.reply');
    // Temp Delete
    $this->route(['POST'], '/messages/edit/trash', Savage\Http\Controllers\AuthController::class, 'trashDirectMessages')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.edit.trash');
    // Restore
    $this->route(['POST'], '/messages/edit/restore', Savage\Http\Controllers\AuthController::class, 'restoreDirectMessages')->add(new \Savage\Http\Filters\AuthFilter($this))->setName('auth.messages.edit.restore');
    // Delete Forever!