在parse.com中设置用户角色和权限 [英] Set up users roles and permissions in parse.com

查看:124
本文介绍了在parse.com中设置用户角色和权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望在parse.com中设置用户权限.我在我的用户表"中有一个已知的用户列表.我想为主管锁定该应用程序(角色),仅查看大多数表并修改一些表.让经理(角色)查看几乎所有表并进行大多数修改.管理员可以查看和修改所有内容.

looking to set up user permissions in parse.com. i have a know list of users in my user "table". i want to lock down the app for supervisors(role) only view most tables and modify a few. have managers(role) to view almost all tables and modify most. Administrators to view and modify all.

搜索几天后,我只看到修改角色和权限的代码.如果角色和权限仅设置一次,使用代码的目的是什么?还是有人可以在在线数据窗口中说明如何设置角色和权限. 谢谢您的帮助

after searching for days i only see code to modify roles and permissions. what is the purpose using code if the roles and permissions are only setup once? or would someone please explain how to set up roles and permissions in the data window online. thanks for your help

我在保存行中收到此错误: https://api.parse.com /1/classes/_Role/24EHbUyDzv 404(未找到)

I get this error on the save line: https://api.parse.com/1/classes/_Role/24EHbUyDzv 404 (Not Found)

我的实用程序示例代码:

my sample code for utility:

// First create a pointer to the object of yourClassName
var user = Parse.Object.extend("User");
var pointer = new user();
pointer.id = "aL5dfXQsRO";

// Now you can add the pointer to the relation
query = new Parse.Query(Parse.Role); 
query.equalTo("name", "manager"); 
query.first ( { 
      success: function(object) { 
      object.relation("users").add(pointer); 
      object.save();
      //response.success("The user has been authorized.");
},

推荐答案

似乎有两种选择可以完成工作.

It looks like there's two options to get the job done.

1)编写一些单一用途的代码来设置角色.角色是一种关系,因此您必须照此创建它们. 此处是Parse工程师对此主题的引用:

1) Write some single-purpose code to set the roles. Roles are a type of relation, so you will have to create them as such. Here is a quote from a Parse engineer on the subject:

要将对象添加到关系列,您需要使用客户端SDK 或REST API.

To add objects to a relation column, you need to use the client SDKs or REST API.

2)此处介绍的解决方法其要点是,您可以导出表的数据,修改角色的数据,然后将更新导入回Parse.这样,您就可以手动设置角色,而不必编写单一用途的代码.

2) The workaround described here. The gist of it is, you can export your table's data, modify data for the roles, and then import the updates back into Parse. This will allow you to manually set the roles without having to write single-purpose code.

这是您的代码示例和更正

Here's your code sample and correction

// First create a pointer to the object of yourClassName
var UserClass = Parse.Object.extend("User");
var userPointer = new UserClass();
userPointer.id = "aL5dfXQsRO";

// Now you can add the pointer to the relation
query = new Parse.Query(Parse.Role); 
query.equalTo("name", "manager"); 
query.first ( { 
    success: function(object) { 
        object.relation("users").add(userPointer); 
        object.save();

这篇关于在parse.com中设置用户角色和权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆