public void UpdateProfile(string email, string firstname, string lastname) { this.HttpContext.Response.ContentType = "text/html"; if (sessionInstance.LoggedIn == false) { this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.Unauthorized; return; } var update = new Majorsilence.Vpn.Logic.Accounts.UserInfo(sessionInstance.UserId); try { update.UpdateProfile(email, firstname, lastname); Majorsilence.Vpn.Logic.ActionLog.Log_BackgroundThread(string.Format("Profile Update - Email -> {0} - First Name -> {1} - Last Name -> {2}", email, firstname, lastname), sessionInstance.UserId); this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.OK; } catch (Majorsilence.Vpn.Logic.Exceptions.InvalidDataException ide) { Majorsilence.Vpn.Logic.Helpers.Logging.Log(ide); this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } catch (Majorsilence.Vpn.Logic.Exceptions.EmailAddressAlreadyUsedException eaaue) { Majorsilence.Vpn.Logic.Helpers.Logging.Log(eaaue); this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } }
public void RetreiveUserInfoTest() { Assert.That(AccountExists(emailAddress), Is.False); var peterAccount = new Majorsilence.Vpn.Logic.Accounts.CreateAccount( new Majorsilence.Vpn.Logic.Accounts.CreateAccountInfo() { Email = emailAddress, EmailConfirm = emailAddress, Firstname = "Peter", Lastname = "Gill", Password = "******", PasswordConfirm = "Password1", BetaKey = "" } , false, Majorsilence.Vpn.Logic.InitializeSettings.Email); var userid = peterAccount.Execute(); Assert.That(AccountExists(emailAddress), Is.True); var info = new Majorsilence.Vpn.Logic.Accounts.UserInfo(userid); var profile = info.GetProfile(); Assert.That("Peter", Is.EqualTo(profile.FirstName)); Assert.That("Gill", Is.EqualTo(profile.LastName)); Assert.That(emailAddress, Is.EqualTo(profile.Email)); Assert.That(false, Is.EqualTo(profile.Admin)); Assert.That(false, Is.EqualTo(profile.IsBetaUser)); }
public void UpdateUserInfoInvalidEmailTest() { Assert.That(AccountExists(emailAddress), Is.False); var peterAccount = new Majorsilence.Vpn.Logic.Accounts.CreateAccount( new Majorsilence.Vpn.Logic.Accounts.CreateAccountInfo() { Email = emailAddress, EmailConfirm = emailAddress, Firstname = "Peter", Lastname = "Gill", Password = "******", PasswordConfirm = "Password1", BetaKey = "" } , false, Majorsilence.Vpn.Logic.InitializeSettings.Email); var userid = peterAccount.Execute(); Assert.That(AccountExists(emailAddress), Is.True); var info = new Majorsilence.Vpn.Logic.Accounts.UserInfo(userid); var profile = info.GetProfile(); Assert.Throws <Majorsilence.Vpn.Logic.Exceptions.InvalidDataException>(() => info.UpdateProfile("", "Happy", "Dude")); }
public Account(int userId) { var profileInfo = new Majorsilence.Vpn.Logic.Accounts.UserInfo(userId).GetProfile(); FirstName = profileInfo.FirstName; LastName = profileInfo.LastName; UsersEmail = profileInfo.Email; ChargeAmount = Majorsilence.Vpn.Logic.Helpers.SiteInfo.CurrentMonthlyRate.ToString("G29"); ChargeAmountStripCents = Majorsilence.Vpn.Logic.Helpers.SiteInfo.CurrentMonthlyRateInCents; var payInfo = new Majorsilence.Vpn.Logic.Payments.Payment(userId); AccountExpired = payInfo.IsExpired(); PaymentHistory = payInfo.History(); }
public void UpdatePassword(string oldpassword, string newpassword, string confirmnewpassword) { this.HttpContext.Response.ContentType = "text/html"; if (sessionInstance.LoggedIn == false) { this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.Unauthorized; return; } var update = new Majorsilence.Vpn.Logic.Accounts.UserInfo(sessionInstance.UserId); try { update.UpdatePassword(oldpassword, newpassword, confirmnewpassword); Majorsilence.Vpn.Logic.ActionLog.Log_BackgroundThread("Password Changed", sessionInstance.UserId); this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.OK; } catch (Majorsilence.Vpn.Logic.Exceptions.InvalidDataException ide) { this.HttpContext.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; } }
public void RemoveUser(int id, string removeaccount) { if (sessionInstance.LoggedIn == false || sessionInstance.IsAdmin == false) { return; } try { if (removeaccount != null && removeaccount == "yes") { var user = new Majorsilence.Vpn.Logic.Accounts.UserInfo(id); user.RemoveAccount(); Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode("User with id removed: " + id), false); } } catch (Exception ex) { Majorsilence.Vpn.Logic.Helpers.Logging.Log(ex); Response.Redirect("/admin/users?status=" + HttpUtility.HtmlEncode(ex.Message), false); } }