xuhuaiqu

第 656 位会员

会员
个人信息
  • 加入于 2018-09-28 18:01:34
  • 最后登录时间 11天前
个人成就
  • 发表文章次数 4
  • 发布回复次数 17
  • 个人主页浏览次数 2
Fecshop 1.6.0.0 发布 - fecshop的完善和安全又上一个新的台阶13天前

PHP 7.0.32 升级出现问题

Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

Problem 1

- yiisoft/yii2 2.0.15.1 requires bower-asset/inputmask ~3.2.2 | ~3.3.5 -> no matching package found.
- yiisoft/yii2 2.0.15.1 requires bower-asset/jquery 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable -> no matching package found.
- yiisoft/yii2 2.0.15 requires bower-asset/jquery 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable -> no matching package found.
- fancyecommerce/fecshop 1.6.0.0 requires yiisoft/yii2 >=2.0.15 -> satisfiable by yiisoft/yii2[2.0.15.1, 2.0.15].
- Installation request for fancyecommerce/fecshop >=1.6.0.0 -> satisfiable by fancyecommerce/fecshop[1.6.0.0].

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

composer 配置文件为 已经生成github token

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Project Template",
    "keywords": ["yii2", "fecshop","cart", "shop", "e-commerce"],
    "homepage": "http://www.fecshop.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "forum": "http://www.fecshop.com/forum/",
        "wiki": "http://www.fecshop.com/wiki/",
        "source": "https://github.com/fancyecommerce/yii2_fecshop_app_advanced"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-apidoc": "~2.0.0",
        "fancyecommerce/fecshop": ">=1.6.0.0"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.0.0",
        "yiisoft/yii2-gii": "~2.0.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/base": "^2.2.3",
        "codeception/verify": "~0.3.1"
    },
    "scripts": {
        "post-install-cmd": "php init --env=Development --overwrite=n"
    },
    "repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://packagist.org"
        }
    },
    "config": {
        "fxp-asset": {
            "installer-paths": {
                "npm-asset-library": "vendor/npm",
                "bower-asset-library": "vendor/bower"
            }
        },
        "process-timeout": 1800,
        "github-oauth": {
          "github.com": "09f8355216c9750c29e5b912450eed424128xxxx"
        }
    },
    "extra": {
    }
}

RBAC 后台菜单的开发使用20天前

Page.php应该为Admin.php 配置文件名错了

1.5.1.1版本发布23天前

@Fecshop #10楼 感谢大佬

1.5.1.1版本发布24天前

@Fecshop #6楼 1.5.0.0 迁移到1.5.1.1

1.5.1.1版本发布24天前

@Fecshop #6楼 确定执行了两个库的迁移 切换到新迁的库 也会报错。我怕有缓存,把整个项目的vendor都替换了一遍。 正是因为执行了数据库迁移。所以admin_role_menu表被删除了

1.5.1.1版本发布24天前

执行了composer update 按照文档中执行完数据库更新 和 mongodb更新 之后管理后台报错(重新安装成功 但是升级的话就不成功):

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xinguyaji.admin_role_menu' doesn't exist in /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php:1258
Stack trace:
#0 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php(1258): PDOStatement->execute()
#1 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php(1148): yii\db\Command->internalExecute('SELECT `menu_id...')
#2 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php(399): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Query.php(237): yii\db\Command->queryAll()
#4 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/ActiveQuery.php(133): yii\db\Query->all(NULL)
#5 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fec_admin/models/AdminMenu.php(78): yii\db\ActiveQuery->all()
#6 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fec_admin/models/AdminMenu.php(96): fecadmin\models\AdminMenu->getActiveMenuIds()
#7 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fec_admin/views/layouts/Menu.php(20): fecadmin\models\AdminMenu->getLeftMenuTreeHtml()
#8 /home/www/xinguyaji/Admin/appadmin/theme/local/theme01/layouts/dashboard.php(124): fecadmin\views\layouts\Menu::getContent()
#9 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/View.php(336): require('/home/www/xingu...')
#10 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/View.php(254): yii\base\View->renderPhpFile('/home/www/xingu...', Array)
#11 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile('/home/www/xingu...', Array, Object(fecshop\app\appadmin\modules\Fecadmin\controllers\IndexController))
#12 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fecshop/app/appadmin/modules/AppadminController.php(85): yii\base\Controller->renderContent('')
#13 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fecshop/app/appadmin/modules/Fecadmin/controllers/IndexController.php(30): fecshop\app\appadmin\modules\AppadminController->render('index')
#14 [internal function]: fecshop\app\appadmin\modules\Fecadmin\controllers\IndexController->actionIndex()
#15 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#17 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('index', Array)
#18 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('fecadmin/index/...', Array)
#19 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#20 /home/www/xinguyaji/Admin/appadmin/web/index.php(77): yii\base\Application->run()
#21 {main}

Next yii\db\Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xinguyaji.admin_role_menu' doesn't exist
The SQL being executed was: SELECT `menu_id` FROM `admin_role_menu` WHERE `role_id` IN ('4', '12') in /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Schema.php:664
Stack trace:
#0 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php(1263): yii\db\Schema->convertException(Object(PDOException), 'SELECT `menu_id...')
#1 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php(1148): yii\db\Command->internalExecute('SELECT `menu_id...')
#2 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Command.php(399): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/Query.php(237): yii\db\Command->queryAll()
#4 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/db/ActiveQuery.php(133): yii\db\Query->all(NULL)
#5 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fec_admin/models/AdminMenu.php(78): yii\db\ActiveQuery->all()
#6 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fec_admin/models/AdminMenu.php(96): fecadmin\models\AdminMenu->getActiveMenuIds()
#7 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fec_admin/views/layouts/Menu.php(20): fecadmin\models\AdminMenu->getLeftMenuTreeHtml()
#8 /home/www/xinguyaji/Admin/appadmin/theme/local/theme01/layouts/dashboard.php(124): fecadmin\views\layouts\Menu::getContent()
#9 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/View.php(336): require('/home/www/xingu...')
#10 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/View.php(254): yii\base\View->renderPhpFile('/home/www/xingu...', Array)
#11 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile('/home/www/xingu...', Array, Object(fecshop\app\appadmin\modules\Fecadmin\controllers\IndexController))
#12 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fecshop/app/appadmin/modules/AppadminController.php(85): yii\base\Controller->renderContent('')
#13 /home/www/xinguyaji/Admin/vendor/fancyecommerce/fecshop/app/appadmin/modules/Fecadmin/controllers/IndexController.php(30): fecshop\app\appadmin\modules\AppadminController->render('index')
#14 [internal function]: fecshop\app\appadmin\modules\Fecadmin\controllers\IndexController->actionIndex()
#15 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#17 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('index', Array)
#18 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('fecadmin/index/...', Array)
#19 /home/www/xinguyaji/Admin/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#20 /home/www/xinguyaji/Admin/appadmin/web/index.php(77): yii\base\Application->run()
#21 {main}
Additional Information:
Array
(
    [0] => 42S02
    [1] => 1146
    [2] => Table 'xinguyaji.admin_role_menu' doesn't exist
)

Copy Stacktrace Search Stackoverflow Search Google Exception
Database Exception – yii\db\Exception
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xinguyaji.admin_role_menu' doesn't exist
The SQL being executed was: SELECT `menu_id` FROM `admin_role_menu` WHERE `role_id` IN ('4', '12')

fecshop google 登陆原理1个月前

@Fecshop #9楼 ok 我重载registerThirdPartyAccountAndLogin吧 谢谢

fecshop google 登陆原理1个月前

问题在于 这两种方式 都是仅仅返回的 我登录成功了 这种状态。 并没有像邮件登录时 进行header头的设置。我也直接使用的actionRegisterThirdPartyAccountAndLogin 来完成的三方登录。这个流程我是理解的。我已经完成了回调客户端,以及客户端请求/customer/google/loginv 这一步,也成功的获取了三方的username等信息。问题是这个新形成的用户的accss token 在这个registerThirdPartyAccountAndLogin 并未设置。所以困惑在这个点。

    protected function actionLoginAndGetAccessToken($email, $password)
    {
        $header = Yii::$app->request->getHeaders();
        if (isset($header['access-token']) && $header['access-token']) {
            $accessToken = $header['access-token'];
        }
        // 如果request header中有access-token,则查看这个 access-token 是否有效
        if ($accessToken) {
            $identity = Yii::$app->user->loginByAccessToken($accessToken);
            if ($identity !== null) {
                $access_token_created_at = $identity->access_token_created_at;
                $timeout = Yii::$service->session->timeout;
                if ($access_token_created_at + $timeout > time()) {
                    return $accessToken;
                }
            }
        }
        // 如果上面access-token不存在
        $data = [
            'email'     => $email,
            'password'  => $password,
        ];
        
        if (Yii::$service->customer->login($data)) {
            $identity = Yii::$app->user->identity;
            $identity->generateAccessToken();
            $identity->access_token_created_at = time();
            $identity->save();
            // 执行购物车合并等操作。
            Yii::$service->cart->mergeCartAfterUserLogin();
            $this->setHeaderAccessToken($identity->access_token);
            return $identity->access_token;
        }
    }
fecshop google 登陆原理1个月前

一个是customer service的方式

    protected function actionLogin($data)
    {
        $model = new $this->_customerLoginModelName();
        $model->email       = $data['email'];
        $model->password    = $data['password'];
        $loginStatus        = $model->login();
        $errors             = $model->errors;
        if (empty($errors)) {
            // 合并购物车数据
            Yii::$service->cart->mergeCartAfterUserLogin();
            // 发送登录信息到trace系统
            Yii::$service->page->trace->sendTraceLoginInfoByApi($data['email']);
        } else {
            Yii::$service->helper->errors->addByModelErrors($errors);
        }

        return $loginStatus;
    }
fecshop google 登陆原理1个月前

一个是YII2.0的原生登录方式

    public function login(IdentityInterface $identity, $duration = 0)
    {
        if ($this->beforeLogin($identity, false, $duration)) {
            $this->switchIdentity($identity, $duration);
            $id = $identity->getId();
            $ip = Yii::$app->getRequest()->getUserIP();
            if ($this->enableSession) {
                $log = "User '$id' logged in from $ip with duration $duration.";
            } else {
                $log = "User '$id' logged in from $ip. Session not enabled.";
            }

            $this->regenerateCsrfToken();

            Yii::info($log, __METHOD__);
            $this->afterLogin($identity, false, $duration);
        }

        return !$this->getIsGuest();
    }
fecshop google 登陆原理1个月前

三方注册调用了两个函数来进行登录

    /**
     * @property  $user | Array ,example:
     * ['first_name' => $first_name,'last_name' => $last_name,'email' => $email,]
     * @property  $type | String 代表第三方登录的名称,譬如google,facebook
     * @return bool
     * 如果用户emai存在,则直接登录,成功后返回true
     * 如果用户不存在,则注册用户,然后直接登录,成功后返回true
     */
    protected function actionRegisterThirdPartyAccountAndLogin($user, $type)
    {
        
        // 查看邮箱是否存在
        $email = $user['email'];
        $customer_one = Yii::$service->customer->getUserIdentityByEmail($email);
        if ($customer_one) {
            $loginStatus = \Yii::$app->user->login($customer_one);
            if ($loginStatus) {
                return true;
            }
            // 不存在,注册。
        } else {
            if (!(isset($user['password']) && $user['password'])) {
                $user['password'] = $this->getRandomPassword();
            }
            $registerData = [
                'email'       => $email,
                'firstname'   => $user['first_name'],
                'lastname'    => $user['last_name'],
                'password'    => $user['password'],
                'type'        => $type,
            ];
            $registerStatus = Yii::$service->customer->register($registerData);
            if ($registerStatus) {
                $loginStatus = Yii::$service->customer->login($registerData);
                if ($loginStatus) {
                    return true;
                }
            }
        }

        return false;
    }
fecshop google 登陆原理1个月前

以 google为例 可以看到调用了三方注册的函数


    /**
     * google账户登录.
     */
    public function accountLogin($full_name, $email)
    {
        $name_arr = explode(' ', $full_name);
        $first_name = $name_arr[0];
        $last_name = $name_arr[1];
        $user = [
            'first_name'    =>$first_name,
            'last_name'    =>$last_name,
            'email'        =>$email,
        ];
        Yii::$service->customer->registerThirdPartyAccountAndLogin($user, 'google');
        $code = Yii::$service->helper->appserver->status_success;
        $data = [];
        $responseData = Yii::$service->helper->appserver->getResponseData($code, $data);
        
        return $responseData;
        //echo '<script>
		//			window.close();
		//			window.opener.location.reload();
		//		</script>';
        //exit;
    }
fecshop google 登陆原理1个月前

@Fecshop [#2楼](#comment2) 查看前端代码 可以看到请求/customer/google/loginv 之后 即保存了返回header中的access-token


var root = process.env.API_ROOT;

export default {
    data () {
        return {
            pageInitUrl: root + '/customer/google/loginv' ,
            errormsg:'',
            refer_url: '',
            correctmsg:''
        }
    },
    created: function(){
        this.pageInit();
    },
    beforeRouteEnter (to, from, next) {
        var website_root = process.env.WEBSITE_ROOT
        var fullPath = from.fullPath
        var name = from.name
        console.log(fullPath);
        console.log(from);  
        if (fullPath !== '/' || typeof(name) === 'undefined' ) {
            var referUrl = website_root + "/#" + fullPath
            console.log(referUrl)
            
        } else {
            referUrl = ''
        }
        next( vm => {
            vm.refer_url = referUrl;
        });  
    },
    methods: {
        pageInit: function(){
            var self = this;
            self.errormsg = '';
            self.correctmsg = '';
            var requestParams = this.$route.query;
            var ajaxData = {};
            for(var x in requestParams){
                ajaxData[x] = requestParams[x];
            }
            $.showIndicator();
            var cookies = self.getTraceAllCookie();
            ajaxData["cookies"] = cookies;
            $.ajax({
                url: self.pageInitUrl,
                async: true,
                timeout: 120000,
                type: 'get',
                headers: self.getRequestHeader(),
                data:ajaxData,
                success:function(reponseData, textStatus,request){
                    $.hideIndicator();
                    if(reponseData.code == 200){
                        self.reloadPage();
                        var traceData = {"refer_url": self.refer_url};
                        var routerQ = self.$route.query
                        for (var k in routerQ) {
                            traceData[k] = routerQ[k]
                        }
                        self.reloadTraceJs(traceData);
                        self.saveReponseHeader(request); 
                    }
                },
                error:function(){
                    $.toast('system error');
                    $.hideIndicator();
                    console.log('get address list page init error');
                }
            });
            
        },
        reloadPage: function(){
            window.close();
			window.opener.location.reload();
        }
        
    
    }
    
    
    
}

Vue.prototype.saveReponseHeader = function (response){
    // fecshop-uuid
    var fecshop_uuid = response.getResponseHeader('fecshop-uuid');
    if(fecshop_uuid){
        var local_fecshop_uuid = window.localStorage.getItem("fecshop-uuid");
        if(local_fecshop_uuid != fecshop_uuid){
            window.localStorage.setItem("fecshop-uuid",fecshop_uuid);
            console.log('save header [fecshop-uuid] ######' + fecshop_uuid);
        }
    }
    
    var access_token = response.getResponseHeader('access-token');
    if(access_token){
        console.log('save header [access-token1]' );
        var local_access_token = window.localStorage.getItem("access-token");
        console.log('save header [access-token2]' );
        if(local_access_token != access_token){
            console.log('save header [access-token3] ######' + access_token);
            window.localStorage.setItem("access-token",access_token);
            
        }
    }
    
    
    
}

fecshop google 登陆原理1个月前

这里accountLogin后,并没能拿到access_token呢。前端(vue)是如何获取身份认证令牌access token的呢

appserver 三方登录流程请教1个月前

@Fecshop #1楼 辛苦哥 我这边在线等

local app 如何继承一个module,为fecshop的module添加新的controller1个月前

@successgdc #1楼 正解。对YII2.0不是很熟,直接上手的Fecshop 🙏

管理后台导出前端js报错2个月前

@Fecshop #1楼 好的 我看看有空提交到github

Your Site Analytics