在loopback nodejs中,没有人可以通过商店模型创建商店详细信息

时间:2017-07-07 06:48:04

标签: node.js loopbackjs

任何人都不允许通过商店模式直接创建 只有管​​理员可以通过用户/ ID /商店

创建商店

通过使用ACL,我拒绝在商店模型中创建细节。但我不知道如何通过管理员创建商店

$source = "F:\pics\2016\071310"
$destination = "C:\test" 
$folder = "K-G\"
$filterKG = [regex] "^K-G.*\.(jpg|gif)"

$bin = Get-ChildItem -Exclude $folder -Path $source -Recurse | Where-Object {($_.Name -match $filterKG) -or ($_.PSIsContainer)}

foreach ($item in $bin){
$new_folder = $item.FullName.ToString().Replace($source,$destination).Replace($item.Name,$folder)

if(-not (Test-Path $new_folder)){
    New-Item -Type dir $new_folder
    Write-Host $new_folder
}
Copy-Item $item.FullName -Destination $item.FullName.ToString().Replace($source,$destination).Replace($item.Name,$folder+$item.Name) 
}

#remove empty folders which where added 
$tdc="C:\test"
do {
  $dirs = gci $tdc -directory -recurse | Where { (gci $_.fullName -Force).count -eq 0 } | select -expandproperty FullName
  $dirs | Foreach-Object { Remove-Item $_ }
} while ($dirs.count -gt 0)

提前致谢

这是我的script.js,

"acls": [
    {
      "principalType": "USER",
      "principalId": "admin",
      "permission": "ALLOW",
      "property": "create"
    },
    {
    "principalType": "ROLE",
    "principalId": "$everyone",
    "permission": "DENY",
    "property": "create"
    }
]

但我仍然收到授权错误

1 个答案:

答案 0 :(得分:0)

如果您希望能够通过Shop模型(User)创建POST /users/{id}/shops作为管理员,则还需要在User上设置正确的ACL。我假设您正确设置了这两个模型之间的关系,并且您已经创建了管理员角色。

user.json(相关部分)

"acls": [
  {
    "accessType": "WRITE",
    "principalType": "ROLE",
    "principalId": "admin",
    "permission": "ALLOW",
    "property": [ "__create__shops" ]
  }
]

您可以在官方LoopBack docs中找到更多相关信息。