Example #1
0
        public static bool Login(string user, string password)
        {
            CurrentUser = null;
            List <User> users = db.Get <User>("SELECT asmens_kodas, vardas, pavarde, slaptazodis, vartotojo_tipas FROM vartotojas");

            foreach (User u in users)
            {
                if (u.PersonalCode == user)
                {
                    if (u.Password == password)
                    {
                        CurrentUser = u;
                        break;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (CurrentUser == null)
            {
                return(false);
            }

            switch (CurrentUser.Type)
            {
            case 1:
                PermissionControl.SetPermissionLevel(PermissionControl.Admin);
                break;

            case 2:
                PermissionControl.SetPermissionLevel(PermissionControl.Teacher);
                break;

            case 3:
                PermissionControl.SetPermissionLevel(PermissionControl.Student);
                break;
            }

            return(true);
        }
Example #2
0
 public static void Logout()
 {
     CurrentUser = null;
     PermissionControl.SetPermissionLevel(PermissionControl.None);
 }