小编gha*_*han的帖子

广播频道的 Laravel 授权不起作用

我正在尝试使用 Laravel 5.4(后端)和 Angular 2(前端)将聊天集成到 web 应用程序中。我有一个独特的广播频道,可以向用户发送消息。每个用户都有自己的渠道是chat-{uuid}uuid是其中还存储了一个聊天表的唯一IDuserID谁可以访问该频道的用户。问题是授权回调永远不会被调用,因此任何用户如果知道uuid. 我不确定我做错了什么

频道.php

// This authorization is never called 
Broadcast::channel('chat-{uuid}', function ($user, $uuid) {
    return false; 
});
Run Code Online (Sandbox Code Playgroud)

NewMessage.php 事件

protected     $message;

public function __construct($message)
{
    $this->message = $message;
}

protected function prepareData()
{
    return [
        'chatID'                => $this->message->chatID,
        'userID'                => $this->message->builderID,
        'message'               => $this->message->message,
        ];

}

public function broadcastWith()
{
    return [
        'message' => $this->prepareData(),
    ];
}

public function broadcastAs()
{
    return 'new.message';
}

public function …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-5 laravel-5.4

6
推荐指数
1
解决办法
964
查看次数

返回promise并从中创建observable时,Typescript Angular2错误

我试图从ionics storage中检索一个令牌,getToken()然后使用它refreshToken()来查看令牌是否已过期,方法是将令牌传递给它,(this.jwtHelper.isTokenExpired(this.token)这将返回true或false,具体取决于令牌是否已过期.我已将评论放在refreshToken()我收到以下错误的位置

错误1:

Error: TS2345:Argument of type '(response: Response) => void' is not assignable to parameter of type '(value: Response) => void'. Types of parameters 'response' and 'value' are incompatible. Type 'Response' is not assignable to type 'Response'. Two different types with this name exist, but they are unrelated. Property 'body' is missing in type 'Response'.

错误2:

Error:(34, 46) TS2339:Property 'token' does not exist on type 'Promise<any>'.

我的代码

import {AuthHttp, JwtHelper, …
Run Code Online (Sandbox Code Playgroud)

typescript ionic-framework ionic2 angular

3
推荐指数
1
解决办法
4164
查看次数

ValueError:系统中找不到外部ID:website.assets_frontend

我正在从 Odoo V13 升级到 V15,并且在构建临时分支时遇到错误,因为我编写了一个用于更改某些样式的自定义模块。

我该如何修复以下错误

File "/home/odoo/src/odoo/odoo/addons/base/models/ir_model.py", line 1928, in _xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: website.assets_frontend
Run Code Online (Sandbox Code Playgroud)
File "/home/odoo/src/odoo/odoo/tools/convert.py", line 693, in _tag_root
    raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing None:4, somewhere inside
<data inherit_id="website.assets_frontend" name="Profile Frontend Assets">
            <xpath expr="//link[last()]" position="after">
                 <link rel="stylesheet" type="text/scss" href="/website_profile_scss_customization/static/src/scss/website_profile.scss" t-ignore="true"/>
        </xpath>
    </data>
Run Code Online (Sandbox Code Playgroud)

完整错误输出

Traceback (most recent call last):
  File "/home/odoo/src/odoo/odoo/tools/cache.py", line 85, in lookup
    r …
Run Code Online (Sandbox Code Playgroud)

python inheritance odoo odoo-13 odoo-15

3
推荐指数
1
解决办法
5265
查看次数

如何在没有用户身份验证的情况下保护 API 端点

我正在使用 angular2 和 lumen 5.4 创建一个 SPA。只能说有两条路线。一种GET返回要显示的 JSON 数据的POST路由,以及一种用于将文件上传到数据库的路由。它是一个无需登录的内部应用程序(这是我无法控制的)。

如何正确保护端点?对于POST上传表单,我可以包含一个隐藏的令牌,但这根本不安全。lumen 的所有身份验证教程都涉及用户登录,这对我来说不是一个选项。

任何示例或教程都会有所帮助,因为我过去一直使用用户身份验证

laravel lumen laravel-5.4 lumen-5.4

1
推荐指数
1
解决办法
4131
查看次数

使用 nginx 在 Laravel API 路由上找不到 404

PHP 7.2我正在尝试使用和设置服务器nginx。当我导航到 Laravel 主页时,我可以加载 Laravel 主页my-site.com/snow,但是我无法API.php加载定义的任何 API 路由。我的所有 API 路由都以/api/like为前缀/api/login404我的所有 API 路由均出现错误。我究竟做错了什么?

location ~ \.php$ {
  include snippets/fastcgi-php.conf;
  # With php-fpm (or other unix sockets):
  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
  # With php-cgi (or other tcp sockets):
  # fastcgi_pass 127.0.0.1:9000;
}

location /snow {
  index index.php;
}

location /snow/api {
  root /var/www/html/snow;
  rewrite ^/api/(.*)$ /$1 break;
  try_files $uri $uri/ /api/index.php$is_args$args;
}

location ~ snow/api/.+\.php$ {
  root /var/www/html/snow;
  rewrite ^/api/(.*)$ /$1 …
Run Code Online (Sandbox Code Playgroud)

php nginx laravel

0
推荐指数
1
解决办法
6676
查看次数