
https://secure.samuraism.com/r
PhpStorm は300円しか割引ありませんが、無いよりは良いですしね。
サムライズムって会社は2018年8月くらい(?)からの日本正規代理店みたいです。

public function middleware($middlewareQueue)
{
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(ErrorHandlerMiddleware::class)
// Handle plugin/theme assets like CakePHP normally does.
->add(AssetMiddleware::class)
// Add routing middleware.
// Routes collection cache enabled by default, to disable route caching
// pass null as cacheConfig, example: `new RoutingMiddleware($this)`
// you might want to disable this cache in case your routing is extremely simple
->add(new RoutingMiddleware($this, '_cake_routes_'))
// Add csrf middleware.
->add(new CsrfProtectionMiddleware([
'cookieName' => 'csrf',
'secure' => true,
'httpOnly' => true,
]));
return $middlewareQueue;
}
// Add csrf middleware.
->add(new CsrfProtectionMiddleware([
'cookieName' => 'csrf',
'secure' => true,
'httpOnly' => true,
]));
public function middleware($middlewareQueue)
{
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(ErrorHandlerMiddleware::class)
// Handle plugin/theme assets like CakePHP normally does.
->add(AssetMiddleware::class)
// Add routing middleware.
// Routes collection cache enabled by default, to disable route caching
// pass null as cacheConfig, example: `new RoutingMiddleware($this)`
// you might want to disable this cache in case your routing is extremely simple
->add(new RoutingMiddleware($this, '_cake_routes_'));
return $middlewareQueue;
}
use Cake\Event\EventManager;
use Cake\Http\Middleware\CsrfProtectionMiddleware;
$cookieName = 'csrf';
if (!empty($_SERVER['REQUEST_URI']) && preg_match('/^\/manage*/', $_SERVER['REQUEST_URI'])) {
$cookieName = 'mcsrf';
}
EventManager::instance()->on(
'Server.buildMiddleware',
function ($event, \Cake\Http\MiddlewareQueue $middlewareQueue) use ($cookieName) {
$middlewareQueue->add(new CsrfProtectionMiddleware([
'cookieName' => $cookieName,
'secure' => true,
'httpOnly' => true,
]));
});
Plugin::load('Manage', ['bootstrap' => true, 'routes' => true]);
<?php
use Cake\Core\Configure;
if (!empty($_SERVER['REQUEST_URI']) && preg_match('/^\/manage*/', $_SERVER['REQUEST_URI'])) {
Configure::write('Session.handler.model','ManageSessions');
Configure::write('Session.cookiePath','/manage/');
}CREATE TABLE `sessions` ( `id` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, `created` datetime DEFAULT CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+ `modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+ `data` blob DEFAULT NULL, -- for PostgreSQL use bytea instead of blob `expires` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `manage_sessions` ( `id` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, `created` datetime DEFAULT CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+ `modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+ `data` blob DEFAULT NULL, -- for PostgreSQL use bytea instead of blob `expires` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
$this->loadComponent('Auth', [
'loginAction' => [
'controller' => 'Users',
'action' => 'login',
],
'authenticate' => [
'Form' => [
'userModel' => 'Users',
'fields' => [
'username' => 'username',
'password' => 'password',
],
'contain' => 'Shops', // 3.1 で非推奨
'scope' => [], // 3.1 で非推奨
'finder' => 'login',
],
],
'authError' => 'ログインをして、ご利用ください。',
'loginRedirect' => [
'controller' => 'Users',
'action' => 'index'
],
'logoutRedirect' => [
'controller' => 'Users',
'action' => 'login'
]
]);
getTableLocator()->get('Users');
$user = $userTable->query()
->contain(['Shops'])
->where([
'Users.code' => $request->getData('code', ''),
'Shops.code' => $request->getData('shop_code', ''),
])
->first();
$password = $request->getData('password', '');
if ($this->passwordHasher()->check($password, $user->password)) {
return $user->toArray();
}
return false;
}
}
$this->loadComponent('Auth', [
'loginAction' => [
'controller' => 'Users',
'action' => 'login',
],
'authenticate' => [
'Form' => [
'userModel' => 'Users',
'fields' => [
'username' => 'username',
'password' => 'password',
],
'contain' => 'Shops', // 3.1 で非推奨
'scope' => [], // 3.1 で非推奨
'finder' => 'login',
],
],
'authError' => 'ログインをして、ご利用ください。',
'loginRedirect' => [
'controller' => 'Users',
'action' => 'index'
],
'logoutRedirect' => [
'controller' => 'Users',
'action' => 'login'
]
]);
$this->loadComponent('Auth', [
'loginAction' => [
'controller' => 'Users',
'action' => 'login',
],
'authenticate' => [
'User' => [],
],
'authError' => 'ログインをして、ご利用ください。',
'loginRedirect' => [
'controller' => 'Users',
'action' => 'index'
],
'logoutRedirect' => [
'controller' => 'Users',
'action' => 'login'
]
]);