/// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Labs                             = new LabsOperations(this);
     GlobalSchedules                  = new GlobalSchedulesOperations(this);
     ArtifactSources                  = new ArtifactSourcesOperations(this);
     ArmTemplates                     = new ArmTemplatesOperations(this);
     Artifacts                        = new ArtifactsOperations(this);
     Costs                            = new CostsOperations(this);
     CustomImages                     = new CustomImagesOperations(this);
     Formulas                         = new FormulasOperations(this);
     GalleryImages                    = new GalleryImagesOperations(this);
     NotificationChannels             = new NotificationChannelsOperations(this);
     PolicySets                       = new PolicySetsOperations(this);
     Policies                         = new PoliciesOperations(this);
     Schedules                        = new SchedulesOperations(this);
     ServiceRunners                   = new ServiceRunnersOperations(this);
     Users                            = new UsersOperations(this);
     Disks                            = new DisksOperations(this);
     Environments                     = new EnvironmentsOperations(this);
     Secrets                          = new SecretsOperations(this);
     VirtualMachines                  = new VirtualMachinesOperations(this);
     VirtualMachineSchedules          = new VirtualMachineSchedulesOperations(this);
     VirtualNetworks                  = new VirtualNetworksOperations(this);
     BaseUri                          = new System.Uri("https://management.azure.com");
     ApiVersion                       = "2016-05-15";
     AcceptLanguage                   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
Esempio n. 2
0
        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
            UsersOperations ops  = new UsersOperations();
            string          pass = pbxPassword.Password;

            ops.ChangePass(pass);
            MessageBox.Show("Password change!");
            LogOut();
        }
Esempio n. 3
0
        private void FetchUserDetails()
        {
            UsersOperations ops  = new UsersOperations();
            User            user = ops.GetUserDetails(Global.LoggedInUser);

            if (user == null)
            {
                MessageBox.Show("Session expired");
                NavigationService.Navigate(new LoginPage());
            }

            Global.LoggedInUser = user;
        }
Esempio n. 4
0
 // GET api/values
 public List <UsersModel> GetTaskDetails()
 {
     try
     {
         using (var userOperation = new UsersOperations())
         {
             return(userOperation.GetUserDetails());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
 // DELETE api/values/5
 public bool Delete(int id)
 {
     try
     {
         using (var userOperation = new UsersOperations())
         {
             return(userOperation.DeleteUserById(id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 // PUT api/values/5
 public bool Put([FromBody] UsersModel record)
 {
     try
     {
         using (var userOperation = new UsersOperations())
         {
             return(userOperation.UpdateUserDetail(record));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     SignedInUser        = new SignedInUserOperations(this);
     Applications        = new ApplicationsOperations(this);
     DeletedApplications = new DeletedApplicationsOperations(this);
     Groups                           = new GroupsOperations(this);
     ServicePrincipals                = new ServicePrincipalsOperations(this);
     Users                            = new UsersOperations(this);
     Objects                          = new ObjectsOperations(this);
     Domains                          = new DomainsOperations(this);
     OAuth2PermissionGrant            = new OAuth2PermissionGrantOperations(this);
     BaseUri                          = new System.Uri("https://graph.windows.net");
     ApiVersion                       = "1.6";
     AcceptLanguage                   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter <DirectoryObject>("objectType"));
     DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter <DirectoryObject>("objectType"));
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Images           = new ImagesOperations(this);
     LabPlans         = new LabPlansOperations(this);
     Operations       = new Operations(this);
     Labs             = new LabsOperations(this);
     OperationResults = new OperationResultsOperations(this);
     Schedules        = new SchedulesOperations(this);
     Users            = new UsersOperations(this);
     VirtualMachines  = new VirtualMachinesOperations(this);
     Usages           = new UsagesOperations(this);
     Skus             = new SkusOperations(this);
     BaseUri          = new System.Uri("https://management.azure.com");
     ApiVersion       = "2021-11-15-preview";
     AcceptLanguage   = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
Esempio n. 9
0
 public User LoginUser(User login)
 {
     try
     {
         operationsObj = new UsersOperations();
         {
             return(operationsObj.LoginUser(login));
         }
     }
     catch (UserException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 10
0
 public bool AddUser(User newUser)
 {
     try
     {
         operationsObj = new UsersOperations();
         {
             return(operationsObj.AddUser(newUser));
         }
     }
     catch (UserException)
     {
         throw;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 11
0
        public void TestInvalidLogin()
        {
            UsersOperations uo = new UsersOperations();

            //Username and password that do not exist
            String username = "******";
            String password = "******";

            try
            {
                //Checking if the result is false, the user does not log in.
                Assert.IsFalse(condition: uo.Login(username, password));
                Assert.IsFalse(condition: uo.IsBlocked(username), message: "User is blocked");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Users             = new UsersOperations(this);
     Applications      = new ApplicationsOperations(this);
     ServicePrincipals = new ServicePrincipalsOperations(this);
     Groups            = new GroupsOperations(this);
     DirectoryObjects  = new DirectoryObjectsOperations(this);
     ApiVersion        = "v1.0";
     BaseUri           = new System.Uri("https://graph.microsoft.com");
     AcceptLanguage    = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
Esempio n. 13
0
        public void LoadToPrivateListBox()
        {
            lbPrivate.Items.Clear();
            try
            {
                UsersOperations ops = new UsersOperations();
                Global.LoggedInUser.PersonalMusic         = ops.GetListPersonalMusic(Global.LoggedInUser.Id);
                Global.LoggedInUser.PersonalMusicId       = ops.GetListPersonalMusicId(Global.LoggedInUser.Id);
                Global.LoggedInUser.PersonalMusicFileType = ops.GetListPersonalMusicFileType(Global.LoggedInUser.Id);

                if (Global.LoggedInUser.PersonalMusic != null)
                {
                    foreach (string song in Global.LoggedInUser.PersonalMusic)
                    {
                        lbPrivate.Items.Add(song);
                    }
                }
            }
            catch (Exception) { };
        }
Esempio n. 14
0
        private void btnLoadFileUser_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog  openFileDialog = new OpenFileDialog();
            MusicOperations mo             = new MusicOperations();
            UsersOperations uo             = new UsersOperations();

            MessageBox.Show("File should be in example format: 'Slayer - Repentless.mp3'\nPress 'Load personal music list' after load music");

            if (openFileDialog.ShowDialog() == true)
            {
                List <string> fileData = mo.LoadFileUser(openFileDialog.FileName, Global.LoggedInUser.Id);
                string        idFile   = fileData[0];
                string        fileType = fileData[1];

                uo.LoadPrivateMusic(openFileDialog.SafeFileName, idFile, fileType);
                MessageBox.Show("Music loaded!");
            }

            //LogOut();
        }
Esempio n. 15
0
        public bool AddUser(User newUser)
        {
            bool sellerAdded = false;

            try
            {
                uv = new UsersOperations();
                {
                    uv.AddUser(newUser);
                }
            }
            catch (UserException)
            {
                throw;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            return(sellerAdded);
        }
Esempio n. 16
0
        public void TestBlockedLogin()
        {
            //This test will check whether the user will be blocked after 3 invalid
            //login attempts.

            UsersOperations uo = new UsersOperations();

            //Username and password that do not exist
            String username = "******";
            String password = "******";

            try
            {
                //Attempting to log in with invalid log in details 3 times so as to be blocked

                //User is not blocked
                Assert.IsFalse(condition: uo.IsBlocked(username), message: "User is blocked");

                //First Attempt
                Assert.IsFalse(condition: uo.Login(username, password));
                //User is not blocked
                Assert.IsFalse(condition: uo.IsBlocked(username), message: "User is blocked");

                //Second Attempt
                Assert.IsFalse(condition: uo.Login(username, password));
                //User is not blocked
                Assert.IsFalse(condition: uo.IsBlocked(username), message: "User is blocked");

                //Third Attempt
                Assert.IsFalse(condition: uo.Login(username, password));
                //User is blocked after the third attempt
                Assert.IsTrue(condition: uo.IsBlocked(username), message: "User is not blocked");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 17
0
        public void TestBlockedUsingDifferentUsernames()
        {
            //This test will check whether the user will be blocked after 3 invalid
            //login attempts using different usernames. (Testing attempts on the same IP Address)

            UsersOperations uo = new UsersOperations();

            //Username and password that do not exist
            String username1 = "Christian10";
            String username2 = "Christian20";
            String username3 = "Christian30";
            String password  = "******";

            try
            {
                //Attempting to log in with invalid log in details 3 times so as to be blocked

                //First Attempt
                Assert.IsFalse(condition: uo.Login(username1, password));
                //User is not blocked
                Assert.IsFalse(condition: uo.IsBlocked(username1), message: "User is blocked");

                //Second Attempt
                Assert.IsFalse(condition: uo.Login(username2, password));
                //User is not blocked
                Assert.IsFalse(condition: uo.IsBlocked(username2), message: "User is blocked");

                //Third Attempt
                Assert.IsFalse(condition: uo.Login(username3, password));
                //Computer is blocked after the third attempt
                Assert.IsTrue(condition: uo.IsBlocked(username3), message: "User is not blocked");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 18
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string mail     = tbxMail.Text;
            string password = pbxPassword.Password;

            UsersOperations ops  = new UsersOperations();
            User            user = ops.AuthenticateUser(mail, password);

            //user.PersonalMusic = ops.GetListPersonalMusic(user.Id);
            //user.PersonalMusicId = ops.GetListPersonalMusicId(user.Id);

            if (user == null)
            {
                MessageBox.Show("Invalid username or password");
                return;
            }
            Global.LoggedInUser = user;

            Global.LoggedInUser.PersonalMusic         = ops.GetListPersonalMusic(Global.LoggedInUser.Id);
            Global.LoggedInUser.PersonalMusicId       = ops.GetListPersonalMusicId(Global.LoggedInUser.Id);
            Global.LoggedInUser.PersonalMusicFileType = ops.GetListPersonalMusicFileType(Global.LoggedInUser.Id);

            NavigationService.Navigate(new DetailPage());
        }
Esempio n. 19
0
 public UsersManager()
 {
     _usersOperations = new UsersOperations(base.IUOW);
 }
        public ActionResult Register(User u)
        {
            UsersOperations uo = new UsersOperations();

            bool status = new AccountsController().VerifyCaptcha(this);

            if (status == false)
            {
                ViewData["error_message"] = "Google reCaptcha validation failed";

                new LogsOperations().AddLog(
                    new Log()
                {
                    Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                    Exception  = "reCaptcha Failed",
                    Time       = DateTime.Now,
                    Message    = "reCaptcha Failed"
                }
                    );
            }

            if (status)
            {
                try
                {
                    if ((u.Password.Length >= 6) && (u.Password.Length <= 15))
                    {
                        if (Regex.IsMatch(u.Password, @"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,15}$"))
                        {
                            if (ModelState.IsValid)
                            {
                                uo.Register(u);
                                ViewData["success_message"] = "User registered successfully";
                                TempData["success_message"] = "User registered successfully";
                                ModelState.Clear();
                                return(RedirectToAction("Login", "Accounts"));
                            }
                            else
                            {
                                new LogsOperations().AddLog(
                                    new Log()
                                {
                                    Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                                    Exception  = "Invalid Model State",
                                    Time       = DateTime.Now,
                                    Message    = "Invalid Model State"
                                }
                                    );
                            }
                        }
                        else
                        {
                            ModelState.AddModelError("Password", "Passwords must contain at least one digit, one uppercase and one lowercase");

                            new LogsOperations().AddLog(
                                new Log()
                            {
                                Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                                Exception  = "Weak password strength",
                                Time       = DateTime.Now,
                                Message    = "Weak password strength"
                            }
                                );
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("Password", "Passwords must be between 6 and 15 characters long");

                        new LogsOperations().AddLog(
                            new Log()
                        {
                            Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                            Exception  = "Invalid password length",
                            Time       = DateTime.Now,
                            Message    = "Invalid password length"
                        }
                            );
                    }
                }
                catch (UsernameExistsException ex)
                {
                    ModelState.AddModelError("Username", ex.Message);

                    new LogsOperations().AddLog(
                        new Log()
                    {
                        Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                        Exception  = ex.Message.ToString(),
                        Time       = DateTime.Now,
                        Message    = ex.Message.ToString()
                    }
                        );
                }
                catch (Exception ex)
                {
                    ViewData["error_message"] = "User registration failed";

                    new LogsOperations().AddLog(
                        new Log()
                    {
                        Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                        Exception  = ex.Message.ToString(),
                        Time       = DateTime.Now,
                        Message    = ex.Message.ToString()
                    }
                        );
                }
            }
            return(View());
        }
 public MainController(UsersOperations operations, TokenOptions token)
 {
     _operations = operations;
     _token      = token;
 }
        public ActionResult Login(string username, string password)
        {
            if (new UsersOperations().IsBlocked(username))
            {
                int time = new UsersOperations().RemainingBlocked(username);
                ViewData["error_message"] = "You are blocked for " + time + " more minutes. Try again later.";

                new LogsOperations().AddLog(
                    new Common.Log()
                {
                    Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                    Exception  = "User blocked",
                    Time       = DateTime.Now,
                    Message    = username + " tried to log in but is currently blocked"
                }
                    );
            }
            else
            {
                bool status = false;
                try
                {
                    status = new AccountsController().VerifyCaptcha(this);
                }
                catch (Exception e)
                {
                    ViewData["error_message"] = e.Message;

                    return(View());
                }

                if (status == false)
                {
                    ViewData["error_message"] = "Google reCaptcha validation failed";

                    new LogsOperations().AddLog(
                        new Common.Log()
                    {
                        Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                        Exception  = "reCaptcha Failed",
                        Time       = DateTime.Now,
                        Message    = username + ": reCaptcha Failed"
                    }
                        );
                }

                if (status)
                {
                    if (new UsersOperations().Login(username, password) == true)
                    {
                        FormsAuthentication.SetAuthCookie(username, true);
                        return(RedirectToAction("Index", "Documents"));
                    }
                    else
                    {
                        new LogsOperations().AddLog(
                            new Common.Log()
                        {
                            Controller = RouteData.Values["controller"].ToString() + "/" + RouteData.Values["action"].ToString(),
                            Exception  = "Invalid Password",
                            Time       = DateTime.Now,
                            Message    = username + ": Invalid Password"
                        }
                            );
                        ViewData["message"] = "An invalid username or password was entered. Please try again.";
                    }
                }
            }

            return(View());
        }
Esempio n. 23
0
 public UserTokensManager()
 {
     _userTokensOperations = new UserTokensOperations(base.IUOW);
     _userOperations       = new UsersOperations(base.IUOW);
 }