OSDN Git Service

バージョン記載追加
[trpgtools-onweb/cake-frame.git] / app / controllers / components / member_auth.php
1 <?php
2 /**
3  * PHP version 5
4  *
5  * @category Component
6  * @package  Chara-Shee!
7  * @version  beta
8  * @author   Cake <cake_67@users.sourceforge.jp>
9  * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
10  * @link     http://trpgtools-onweb.sourceforge.jp/
11  */
12 /*
13  * 一般メンバー認証コンポーネント
14  */
15
16 /**
17  * The parent component
18  */
19 App::import('Component', 'Auth');
20
21 class MemberAuthComponent extends AuthComponent {
22
23 /**
24  * The name of the model that represents users which will be authenticated.  Defaults to 'User'.
25  *
26  * @var string
27  * @access public
28  */
29         var $userModel = 'Member';
30
31         var $isAdmin = false;
32
33         function initialize(&$controller)
34         {
35                 parent::initialize($controller);
36
37                 // 管理画面と一般ユーザ識別
38                 if (isset($controller->params["prefix"]) && $controller->params["prefix"] == Configure::read('Routing.admin')) {
39                         $this->isAdmin = true;
40                 }
41
42                 // 管理画面はUsers、一般ユーザはMembersで認証
43                 if ($this->isAdmin === true) {
44                         $this->userModel = 'User';
45                         $this->loginAction = Router::normalize(array('controller' => 'users', 'action' => 'login'));
46
47                 } else {
48                         Configure::write('Session.cookie', 'CAKEPHPMEMBERSAUTH');
49
50                         // ログイン後リダイレクト設定
51                         $this->loginRedirect = $controller->params["url"]["url"];
52                         if ("/".$this->loginRedirect == Router::normalize(Configure::read('Routing.loginPath'))) {
53                                 $this->loginRedirect = Router::normalize(Configure::read('Routing.basePath'));
54                                 if (Configure::read('mobile')) {
55                                         $this->loginRedirect .= "m/";
56                                 }
57                         }
58                 }
59         }
60
61
62 }
63
64