这个插件是 开放平台的扫码登录 如果微信里面要用的话 需要修改如下文件
/vendor/flarum/core/src/Core/Command/RegisterUserHandler.php
找到下面这句注释掉
if ($avatarUrl = array_get($data, 'attributes.avatarUrl')) {
/assets/forum-9c15ade4.js
搜索authenticationComplete
修改if为
if (payload.authenticated) {
if(window.location.href.indexOf("wechat_user") != -1){
window.location.href="http://www.jdaile.com";
}else{
window.location.reload();
}
}
最后添加
$(function () {
if(window.location.href.indexOf("wechat_user") != -1){
var log=JSON.parse(decodeURIComponent(window.location.href.split("=")[1]));
window.app.authenticationComplete(log);
}
});
/vendor/flarum/core/src/Forum/AuthenticationResponseFactory.php
getResponse 方法 修改为
private function getResponse(array $payload)
{
// print_r(json_encode($payload));die();
// $content = sprintf(
// '<script>window.opener.app.authenticationComplete(%s); window.close();</script>',
// json_encode($payload)
// );
$content = sprintf(
'<script>
window.location.href="http://www.jdaile.com/?&wechat_user="+encodeURIComponent(JSON.stringify(%s));
</script>',
json_encode($payload)
);
return new HtmlResponse($content);
}
flarum 微信登录修改
最新推荐文章于 2023-04-21 11:47:08 发布