コード例 #1
0
ファイル: Service.php プロジェクト: vincium/bourg-la-reine
 public static function saveSecure(\Rebond\Core\User\Model $user, $type)
 {
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $secure = Util\Security::encrypt($user->getEmail() . $ip);
     if ($type == Model::REMEMBER) {
         $expire = time() + 60 * 60 * 24 * 7;
         // 7 days
         setcookie('signedUser', $secure, $expire, '/', Util\Nav::removePort(\Rebond\Config::getPath('siteUrl')));
         $options = [];
         $options['where'][] = ['user_id = ?', $user->getId()];
         $options['where'][] = ['type = ?', Model::REMEMBER];
         $userSecure = Data::load($options);
         if (isset($userSecure)) {
             return $userSecure;
         }
     }
     $userSecure = new Model();
     $userSecure->setUserId($user->getId());
     $userSecure->setSignIn($user->getEmail());
     $userSecure->setSecure($secure);
     $userSecure->setType($type);
     $userSecure->save();
     return $secure;
 }