在我们的应用程序用户注销时,我们通过这种方式使该特定设备的访问令牌无效.
$user = $request->user();
$value = $request->bearerToken();
$id = (new Parser())->parse($value)->getHeader('jti');
$token = $user->tokens->find($id);
$token->revoke();
Run Code Online (Sandbox Code Playgroud)
但是当用户停用他/她的帐户时,我们希望从用户登录的所有设备中使所有访问令牌无效.我查看了文档但没有找到任何有用的内容.谢谢
我的问题:我需要在我尝试使用 laravel 开发的简单 api 中使用分页。我正在使用游标来做到这一点。但是即使我的模型正在返回结果,结果也是空白的。
我的代码:
$newCursor = $groups->last()->id;
$cursor = new Cursor($cursor, $previousCursor, $newCursor, $groups->count());
//dd($cursor);
$groups = new Collection(fractal($groups, new GroupRequestTransformer('filtered')));
$groups->setCursor($cursor);
$data = [
'groups' => $groups,
'cursor' => $cursor
];
$this->setResponseStatus(true, 200, trans('group.filtered'));
return $this->sendResponseData($data);
Run Code Online (Sandbox Code Playgroud)
注意:$groups具有从模型返回的值。如果我dd($cursor);,我得到
Cursor {#403
#current: "5"
#prev: null
#next: 13
#count: 1
}
Run Code Online (Sandbox Code Playgroud)
所以这似乎很好。但是我发送的实际响应$data是空白的。
"data": {
"groups": {},
"cursor": {}
}
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么?
我正在尝试使用 POST 表单将浏览器上传到我的 s3 存储桶。我正在使用eddturtle/direct-upload生成策略和签名。这是我的代码:
$upload = new Signature(
self::S3_KEY,
self::S3_SECRET,
self::S3_BUCKET,
self::S3_REGION
);
Run Code Online (Sandbox Code Playgroud)
并使用方法生成html $upload->getFormInputsAsHtml()。生成这样的html
<form action="//s3.amazonaws.com/bucket" method="POST" enctype="multipart/form-data" class="upload-form">
<input type="hidden" name="Content-Type" value="">
<input type="hidden" name="acl" value="public-read">
<input type="hidden" name="success_action_status" value="201">
<input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjoiMjAxNy0wMi0xNVQxMzowNDozOFoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJ0YWdmaSJ9LHsiYWNsIjoicHJpdmF0ZSJ9LFsic3RhcnRzLXdpdGgiLCIka2V5IiwiIl0sWyJzdGFydHMtd2l0aCIsIiRDb250ZW50LVR5cGUiLCIiXSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDUyNDI4ODAwMF0seyJzdWNjNzX2FjdGlvbl9zdGF0dXMiOiIyMDEifSx7IngtYW16LWNyZWRlbnRpYWwiOiJBS0lBSkhGS0hKMklLNjZTVFA0QVwvMjAxNzAyMTVcL3VzLWVhc3QtMVwvczNcL2F3czRfcmVxdWVzdCJ9LHsieC1hbXotYWxnb3JpdGhtIjoiQVdTNC1ITUFDLVNIQTI1NiJ9LHsieC1hbXotZGF0ZSI6IjIwMTcwMjE1VDA3MDQzOFoifV19">
<input type="hidden" name="X-amz-credential" value="AKIAJHFKHJ2IK66STP4A/20170215/us-east-1/s3/aws4_request">
<input type="hidden" name="X-amz-algorithm" value="AWS4-HMAC-SHA256">
<input type="hidden" name="X-amz-date" value="20170215T070438Z">
<input type="hidden" name="X-amz-signature" value="e9d30613e4fcab8fec3fe75c4ce2969bb6497d83af7cca7f9ea6a1c0738844c5">
<input type="hidden" name="key" value="${filename}">
</form>
Run Code Online (Sandbox Code Playgroud)
但提交表单后,我从 s3 收到此错误
<Error>
<Code>InvalidArgument</Code>
<Message>Malformed Unicode code sequence in the field.</Message>
<ArgumentName>formField</ArgumentName>
<RequestId>46E52494FC98ED76</RequestId>
<HostId>
Qk/g94sJSfVicIxPb3oFN0nO1EVCvxy8YzBQjRKyKpATZZmX1VjlDK+zWfvidhZl5vuemZyuKg0=
</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)
示例请求负载 …
我知道我可以创建用户组并从django项目的管理区域为他们分配权限.我还可以通过从django的auth模块导入Group和Permission建模来创建一个组并为其分配权限.
在设置项目时,如果有任何方法可以创建组并为其分配权限,我想知道什么.所以,如果我有类型的用户,Admin,Developer,Tester和Project Manager.它们基本上是具有不同权限级别的用户组.我没有自定义User模型,只能区分它们所分配的组.那么有没有办法创建这些组并为它们分配所需的权限,例如在我运行时为admin创建权限时python manage.py migrate?
我有搜索页面,我正在其中使用更新后的过滤器值更新查询字符串$router.replace({params: filters});。但是,当我使用客户端导航从另一个页面导航到过滤器页面时,导航$router.replace()将被中止。这是我的代码:
成分
<filter-section
@filterSearch="filter"
@toggleView="handleToggleView"
:currentlySelected="view_type"
@mapViewMounted="loadMarkers" />
Run Code Online (Sandbox Code Playgroud)
方法
async filter(filters) {
this.listLoading = true;
this.APPLY_SEARCH_FILTER(filters);
// changes the query parameters in the url to be in sync with the current filters
this.$router.replace({query: filters}, () => {
// when the page is refreshed and the page is server rendered
// then this is working fine
console.log('Route replace complete');
}, () => {
// when navigated to this page using client side
// routing the route …Run Code Online (Sandbox Code Playgroud) 我是新手,jest所以我不确定是不是我的错。所以这是我的测试用例
it('should throw error if wrong email or phone number is provided', async () => {
await expect(userService.verifyCredentials('invalidemail@invaliddomain.com', 'sayantan94'))
.rejects
.toEqual(new UnauthorizedException('Invalid email or phone number'));
})
Run Code Online (Sandbox Code Playgroud)
但是即使抛出相同的异常,这也会失败。这是输出
FAIL src/modules/user/user.service.spec.ts (5.156s)
? UserService › verifyCredentials › should throw error if wrong email or phone number is provided
expect(received).toStrictEqual(expected)
Expected value to equal:
[Error: [object Object]]
Received:
[Error: [object Object]]
Difference:
Compared values have no visual difference.
88 | await expect(userService.verifyCredentials('invalidemail@invaliddomain.com', 'sayantan94'))
89 | .rejects
> 90 | .toEqual(new …Run Code Online (Sandbox Code Playgroud) 我在 Laravel 应用程序中写入日志时面临权限问题。我们有每日日志,因此每天都会创建一个新的日志文件。项目文件夹所有权设置为www-data. 并且日志通常是经过www-data许可生成的。但有时日志是由root用户创建的,然后如果我尝试在日志中写入内容,我会被拒绝并且应用程序崩溃。
-rw-r--r-- 1 www-data www-data 77016 Sep 12 05:00 laravel-2017-09-11.log
-rw-r--r-- 1 root root 1240 Sep 12 10:30 laravel-2017-09-12.log
Run Code Online (Sandbox Code Playgroud)
For example, yesterday's log was created by www-data but today it's under root. So I am getting crashes everytime. If I delete the log or change the permission to 777 then it solves for a while until it pops up again. I cannot replicate the issue and don't know why logs …