public async Task <CommonMessage> Allow( string userId, string resource, string action, string _namespace, CancellationToken cancellationToken = default) { var param = new AllowParam(resource, action) { UserId = userId, Resource = resource, Namespace = _namespace }; var res = await client.Request <AllowResponse>(param.CreateRequest(), cancellationToken); return(res.Result); }
/// <summary> /// 允许某个用户操作某个资源 /// </summary> /// <param name="resource"></param> /// <param name="action"></param> /// <param name="userId"></param> /// <param name="role"></param> /// <param name="cancellationToken"></param> /// <returns></returns> /// TODO: 下个大版本去除 /// WARNING: 去除 CancellationToken cancellationToken = default 参数以避免与重载函数冲突 public async Task <CommonMessage> Allow( string resource, string action, string userId = null, string role = null ) { var param = new AllowParam(resource, action) { UserId = userId, RoleCode = role, }; await client.GetAccessToken(); var res = await client.Request <AllowResponse>(param.CreateRequest()); return(res.Result); }
/// <summary> /// 允许某个用户操作某个资源 /// </summary> /// <param name="resource"></param> /// <param name="action"></param> /// <param name="userId"></param> /// <param name="role"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <CommonMessage> Allow( string resource, string action, string userId = null, string role = null, CancellationToken cancellationToken = default) { var param = new AllowParam() { Resource = resource, Action = action, UserId = userId, RoleCode = role, }; await client.GetAccessToken(); var res = await client.Request <AllowResponse>(param.CreateRequest(), cancellationToken); return(res.Result); }