Esempio n. 1
0
 public static User FindUserById(string id)
 {
     using(Entities db = new Entities())
     {
         return db.User.FirstOrDefault(s => s.UserId.Equals(id));
     }
 }
Esempio n. 2
0
 public static string FullNameById(string id)
 {
     using (Entities db = new Entities())
     {
         var user = db.User.FirstOrDefault(s => s.UserId.Equals(id));
         return (user == null) ? null : user.FullName;
     }
 }
Esempio n. 3
0
        private static List<string> CurrentPermissions()
        {
            using (Entities db = new Entities())
            {
                if (IsAuthenticated())
                {
                    // ha bejelentkezett felhasnzálóval van dolgunk, kérdezzük le a jogait
                    return db.GetCurrentPermissions(HttpContext.Current.User.Identity.GetUserId()).ToList();
                }
                else
                {
                    // ha nincs bejelentkezve, akkor az anonymous jogokat kérdezzük le
                    return db.Role.SingleOrDefault(r => r.Name.ToLower().Equals("anonymous")).Permission.Select(p => p.Name).ToList();
                }

            }
        }
Esempio n. 4
0
        //public const string SUPERUSER = "******";
        public static User CurrentUser()
        {
            if (IsAuthenticated())
            {
                using (Entities db = new Entities())
                {
                    var uid = HttpContext.Current.User.Identity.GetUserId();
                    var user = db.User.SingleOrDefault(u => u.UserId.Equals(uid));

                    //ha authenticated(van sütije), de ez mégis null-t ad vissza, akkor vmi turpisság van a dologban!!
                    if (user == null)
                    {
                        throw new UnauthorizedAccessException();
                    }

                    return user;
                }
            }
            else
            {
                return new User { UserName = "******" };
            }
        }