Fecmall

第 2 位会员

会员
个人信息
  • 加入于 2017-05-31 17:38:45
  • 城市 Qingdao
  • GitHub https://github.com/fecshop
  • 最后登录时间 7天前
  • 签名 净化自己,潜心编码
个人简介
Terry,Fecmall开源产品作者,12年电商经验一线程序员开发者,擅长规划产品,架构设计。
个人成就
  • 发表文章次数 744
  • 发布回复次数 5760
  • 个人主页浏览次数 683
请问APPSERVER下面的API的登录态过期时间在哪里配置?6年前

@zks888 #2楼

上面说错了,超时时间是 $timeout = Yii::$service->session->timeout;

if ($access_token_created_at + $timeout > time()) {
                // 如果时间没有过期,但是快要过期了,在过$updateTimeLimit段时间就要过期,那么更新access_token_created_at。
                $updateTimeLimit = Yii::$service->session->updateTimeLimit;
                if ($access_token_created_at + $timeout <= (time() + $updateTimeLimit)) {
                    $identity->access_token_created_at = time();
                    $identity->save();
                }
                return $identity;
            } else {
                $this->logoutByAccessToken();
                return null;
            }

1.登陆状态过期时间为:$timeout = Yii::$service->session->timeout;

2.到期后,就需要重新登陆,为了可以让持续用户访问用户不过期,就需要每次访问都更新$identity->access_token_created_at,但是这对数据库的update会有压力,因此,当用户访问到达一个阀值,在更新 access_token_created_at, 这个值就是 updateTimeLimit, 如果时间没有过期,但是快要过期了,在过$updateTimeLimit段时间就要过期,那么更新access_token_created_at

因此如果updateTimeLimit设置为0,那么到期后,就需要用户重新登陆,如果设置了这个值,用户会在token快要过去的时候进行更新

因此过期时间是:$timeout = Yii::$service->session->timeout; , 您也需要设置updateTimeLimit, updateTimeLimit 需要比 $timeout 小,譬如:

过期时间设置6 60 60 (6小时),然后设置 updateTimeLimit为 30 * 60 (半小时),那么用户登陆后,过期时间为6小时,当用户在5个小时30分钟的时候访问,那么就会达到阀值,就会更新$identity->access_token_created_at = time();,token的过期时间又会重新变成6小时,这样用户持续访问可以一直在线,又不会对数据库造成压力

当然,最好的方式还是jwt,但是用这种方式,yii2 user的很多东西就不能用了,因此,目前用的还是yii2 user这一套实现的

如果并发大,可以考虑重写一下,将其放到redis等高性能的数据库里面

后台权限问题6年前

如果你还存在问题,写清楚你的问题,点击哪个菜单出现问题,提供足够的信息

1.6.0版本——后台菜单——菜单管理访问报错求助,提示:admin_role_menu' doesn't exist6年前

菜单管理被注视掉了,没有这个菜单了,https://github.com/fecshop/yii2_fecshop/blob/master/config/services/Admin.php

你为什么要打开这个注释?菜单管理在配置文件里面,就是上面的地址,而不是在后台,这是新版改动

seesion 保存失效6年前

关于session部分,看这个url的回帖:http://www.fecshop.com/topic/1566

seesion 保存失效6年前

一般都是没有问题了,你debug一下,为什么session没有被保存,这个是你的个人问题,不是代码bug,大家的都是可以的

请问APPSERVER下面的API的登录态过期时间在哪里配置?6年前

按照代码排查一下就知道了,你想要的是appserver用户的登陆过期时间

1.所有的登陆后的controller,都继承这个类 https://github.com/fecshop/yii2_fecshop/blob/master/app/appserver/modules/AppserverTokenController.php#L71

在71行代码可以看到,登陆验证是:use fecshop\yii\filters\auth\QueryParamAuth;

打开这个文件:https://github.com/fecshop/yii2_fecshop/blob/master/yii/filters/auth/QueryParamAuth.php

可以看到:

 $identity = Yii::$service->customer->loginByAccessToken(get_class($this));

也就是登陆是这个部分

2.继续找

打开:https://github.com/fecshop/yii2_fecshop/blob/master/services/Customer.php#L675

可以看到代码

/** @var \fecshop\models\mysqldb\Customer|null $identity */
        $identity = Yii::$app->user->loginByAccessToken($accessToken, $type);
        if ($identity !== null) {
            $access_token_created_at = $identity->access_token_created_at;
            $timeout = Yii::$service->session->timeout;
            // 如果时间没有过期,则返回 identity
            if ($access_token_created_at + $timeout > time()) {
                // 如果时间没有过期,但是快要过期了,在过$updateTimeLimit段时间就要过期,那么更新access_token_created_at。
                $updateTimeLimit = Yii::$service->session->updateTimeLimit;
                if ($access_token_created_at + $timeout <= (time() + $updateTimeLimit)) {
                    $identity->access_token_created_at = time();
                    $identity->save();
                }
                return $identity;
            } else {
                $this->logoutByAccessToken();
                return null;
            }
        }

https://github.com/fecshop/yii2_fecshop/blob/master/yii/filters/auth/QueryParamAuth.php#L27

过期时间就是$updateTimeLimit = Yii::$service->session->updateTimeLimit;

就是session services 的 updateTimeLimit配置的,也就是这里配置的: https://github.com/fecshop/yii2_fecshop/blob/master/config/services/Session.php#L22

你在本地@appserver/config/fecshop_local_services/ 下面的Session.php(没有这个文件自行创建),重写配置就可以了

如果你不明白如何重写,那么手把手的和你说一下

1.新建文件@appserver/config/fecshop_local_services/Session.php ,将 https://github.com/fecshop/yii2_fecshop/blob/master/config/services/Session.php#L22 里面的内容复制进去,然后把除了 'updateTimeLimit' => 600,其他的子项去掉,然后设置这个值就可以了。

后台权限问题6年前

刷新下缓存试试?

1.6.0.0这个版本已经修复这个问题了

seesion 保存失效6年前

那个端口调用?

自己debug一下原因

fecshop 性能测速6年前

最近优化一下性能,将缓存部分完善起来。

fecshop小部件6年前

@dream #3楼 开发过程中的代码结构调整,有一些注释没有改过来,这个改一下注释

fecshop小部件6年前

render() 和 函数 renderContent(), 是两个函数

render() 在这里有讲解:http://www.fecshop.com/doc/fecshop-guide/instructions/cn-1.0/guide-fecshop_widget.html

对于 renderContent() 函数, category_product_price,是可以随便写的,只是用于标记,和出问题的时候报错

protected function actionRenderContent($configKey, $config, $parentThis = '')
    {
        if (isset($config['cache']['enable']) && $config['cache']['enable']) {
            if (!isset($config['class']) || !$config['class']) {
                throw new InvalidConfigException('in widget ['.$configKey.'],you enable cache ,you must config widget class .');
            } elseif ($ob = new $config['class']()) {
                if ($ob instanceof BlockCache) {
                    $cacheKey = $ob->getCacheKey();
                    if (!($content = CCache::get($cacheKey))) {
                        $cache = $config['cache'];
                        $timeout = isset($cache['timeout']) ? $cache['timeout'] : 0;
                        unset($config['cache']);
                        $content = $this->renderContentHtml($configKey, $config, $parentThis);
                        CCache::set($cacheKey, $content, $timeout);
                    }

                    return $content;
                } else {
                    throw new InvalidConfigException($config['class'].' must implete fecshop\interfaces\block\BlockCache  when you use block cache .');
                }
            }
        }
        // 查看 $config['class'] 是否在YiiRewriteMap重写中存在配置,如果存在,则替换
        $config['class'] = Yii::mapGetClassName($config['class']);
        $content = $this->renderContentHtml($configKey, $config, $parentThis);

        return $content;
    }
fecshop小部件6年前

写一下文件路径?

图片链接地址加http6年前

目前的这种方式可以很好的兼顾浏览器下的http和https,但是app是没网址的,只能加http

图片链接地址加http6年前

安装fecshop,有配置图片的步骤

就是文件:@common/config/fecshop_local_services/Image.php

当然,这个设置是全局的,各个入口统一的设置,如果你想你的某个入口进行单独的设置,那么你在

@app/config/fecshop_local_services/Image.php 中配置,这里的配置就会覆盖@common的

如果@app没有这个文件,创建,从common复制过去内容覆盖,然后修改就行了

<?php
/**
 * FecShop file.
 *
 * @link http://www.fecshop.com/
 *
 * @copyright Copyright (c) 2016 FecShop Software LLC
 * @license http://www.fecshop.com/license/
 */
return [
    'image' => [
        'appbase'    => [
            'appfront' => [
                'basedir'    => '@appimage/appfront',
                'basedomain' => '//img.appfront.fancyecommerce.com',
            ],
            'apphtml5' => [
                'basedir'    => '@appimage/apphtml5',
                'basedomain' => '//img.apphtml5.fancyecommerce.com',
            ],
            //'appadmin' => [
            //	'basedir' => '@appimage/appadmin',
            //	'basedomain' => '//img.appadmin.fancyecommerce.com',
            //],
            'common' => [
                'basedir'    => '@appimage/common',
                'basedomain' => '//img.fancyecommerce.com',
            ],
        ],
    ],
];

//img.appfront.fancyecommerce.com 改成 https://img.appfront.fancyecommerce.com

fecshop 性能测速6年前
ab -n 100 -c 10

100个用户,持续访问10秒吧?

这个测试环境是手工搭建的(阿里云),不是docker,为了忽略网络延迟,在/etc/hosts中将域名映射到127.0.0.1

centos7.5 启动ssh1失败6年前

google 搜索一下吧;oci runtime create failed : starting container process caused sshd

不能翻墙,就开一下蓝灯

蓝灯:https://github.com/getlantern/lantern/

每天有一定的免费流量

Fecshop 1.6.0.0 发布 - fecshop的完善和安全又上一个新的台阶6年前

@tgy3300 #11楼 仔细看看升级文档的操作

需要升级数据库,另外外层包的文件需要手动更新

Your Site Analytics