コード例 #1
0
 /// <summary>
 /// 锁定用户
 /// </summary>
 /// <param name="id"></param>
 public void LockUser(string id)
 {
     Broker.ExecuteTransaction(() =>
     {
         var userId = UserIdentityUtil.GetCurrentUserId();
         AssertUtil.CheckBoolean <SpException>(userId == id, "请勿锁定自己", "4B1DD6F4-977B-43B4-BA48-C02668A661B3");
         var data = Broker.Retrieve <auth_user>("select * from auth_user where user_infoid = @id", new Dictionary <string, object>()
         {
             { "@id", id }
         });
         data.is_lock = true;
         UpdateData(data);
     });
 }
コード例 #2
0
ファイル: AuthAccess.cs プロジェクト: CarlDuFromChina/blog
        /// <summary>
        /// 检查权限
        /// </summary>
        /// <param name="objectid"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        private static bool CheckAccess(string objectid, OperationType operationType, string userId)
        {
            var data = UserPrivilegesCache.GetUserPrivileges(string.IsNullOrEmpty(userId) ? UserIdentityUtil.GetCurrentUser()?.Id : userId)
                       .Where(item => item.objectid == objectid)
                       .FirstOrDefault();

            return(data != null && (data.privilege & (int)operationType) == (int)operationType);
        }