public ServerResponse deleteWidget(int id, int widgetid) { ServerResponse sr; sr = UserUtilities.deleteUserWidget(widgetid); return(sr); }
public ServerResponse getMail(int id) { ServerResponse sr; sr = UserUtilities.getAllMail(id); return(sr); }
public ServerResponse getWidget(int id, int widgetid) { ServerResponse sr; sr = UserUtilities.getUserWidget(widgetid); return(sr); }
public ServerResponse getDashboard(int id) { ServerResponse sr; sr = UserUtilities.getUserDashboard(id); return(sr); }
public ServerResponse UserLogout([FromBody] logoutModel logoutinfo) { bool success = true; string message = ""; ServerResponse sr; if (logoutinfo == null) { success = false; message = "no data in payload"; } else if (logoutinfo.id == -1) { success = false; message = "id invalid"; } if (success) { sr = UserUtilities.logoutUser(logoutinfo.id); } else { sr = new ServerResponse(success, message, null); } return(sr); }
public ServerResponse Userlogin([FromBody] LoginModel logininfo) { bool success = true; string message = ""; if (logininfo == null) { success = false; message = "no data in payload"; } else if (logininfo.email == null) { success = false; message = "no email specified"; } else if (logininfo.password == null) { success = false; message = "no password specified"; } ServerResponse sr; if (success) { sr = UserUtilities.loginUser(logininfo.email, logininfo.password); } else { sr = new ServerResponse(success, message, null); } return(sr); }
public ActionResult Edit(int id) { var context = new Context(); if (!Request.IsAjaxRequest()) { var log = new SysLogModel(context: context); var html = UserUtilities.Editor( context: context, ss: SiteSettingsUtilities.UsersSiteSettings(context: context), userId: id, clearSessions: true); ViewBag.HtmlBody = html; log.Finish(context: context, responseSize: html.Length); return(View()); } else { var log = new SysLogModel(context: context); var json = UserUtilities.EditorJson( context: context, ss: SiteSettingsUtilities.UsersSiteSettings(context: context), userId: id); log.Finish(context: context, responseSize: json.Length); return(Content(json)); } }
public async Task <AuthenticationResult> LoginAsync(string emailOrUserName, string password) { User user; if (UserUtilities.IsValidEmail(emailOrUserName)) { user = await _userManager.FindByEmailAsync(emailOrUserName); } else { user = await _userManager.FindByNameAsync(emailOrUserName); } if (user == null) { return(new AuthenticationResult { Errors = new[] { "User does not exist" } }); } var validPassword = await _userManager.CheckPasswordAsync(user, password); if (!validPassword) { return(new AuthenticationResult { Errors = new[] { "Incorrect Password" } }); } return(await GenerateAuthResultAsync(user)); }
public IHttpActionResult PutUser([FromBody] User user) { var currentId = UserUtilities.GetCurrentUserId(User); //var currentId = id; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (currentId != user.UserId) { return(Unauthorized()); } db.Entry(user).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(currentId)) { return(NotFound()); } else { throw; } } return(Ok(user)); }
public ActionResult Login(string returnUrl) { var context = new Context(); var log = new SysLogModel(context: context); if (Sessions.LoggedIn()) { if (QueryStrings.Bool("new")) { Authentications.SignOut(); } log.Finish(context: context); return(base.Redirect(Locations.Top())); } var html = UserUtilities.HtmlLogin( context: context, returnUrl: returnUrl, message: Request.QueryString["expired"] == "1" && !Request.IsAjaxRequest() ? Messages.Expired().Text : string.Empty); ViewBag.HtmlBody = html; log.Finish(context: context, responseSize: html.Length); return(View()); }
public ActionResult Login(string returnUrl) { var log = new SysLogModel(); if (Sessions.LoggedIn()) { if (Libraries.Requests.QueryStrings.Bool("new")) { Authentications.SignOut(); } else { log.Finish(); return(base.Redirect(Locations.Top())); } } var html = UserUtilities.HtmlLogin( returnUrl, Request.QueryString["expired"] == "1" && !Request.IsAjaxRequest() ? Messages.Expired().Html : string.Empty); ViewBag.HtmlBody = html; log.Finish(html.Length); return(View()); }
/// <summary> /// Handles the Click event of the _btnLogin control. /// </summary> /// <param name = "sender">The source of the event.</param> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> protected void _btnLogin_Click(object sender, EventArgs e) { if (_txtEmail.Text.Trim() == String.Empty || _txtPassword.Text.Trim() == String.Empty) { WriteFeedBackMaster(FeedbackType.Warning, "Please enter a username and password."); } if (!UserUtilities.Login(_txtEmail.Text.Trim(), _txtPassword.Text.Trim())) { return; } FormsAuthentication.SignOut(); Session.RemoveAll(); //add Session stuff here!! var userObj = new CurrentUserObj(_txtEmail.Text.Trim()); Session["currentUser"] = userObj; Session.Timeout = 60; FormsAuthentication.SetAuthCookie(_txtEmail.Text.Trim(), true); SetLoginControls(); RadAjaxManager.GetCurrent(Page).Redirect("~/App/Pages/MyAccount.aspx"); }
///<summary> /// Gets a user record by email address ///</summary> public User GetUser(string emailAddress) { try { DataTable users = ApplicationData.GetInstance().DataSet.Tables["everbank_users"]; DataRow[] results = users.Select($"email_address = '{UserUtilities.ConformString(emailAddress)}'"); if (results.Length > 0) { DataRow row = results[0]; User user = new User() { EmailAddress = row.Field <string>("email_address"), FirstName = row.Field <string>("first_name"), Id = row.Field <int>("uid"), Password = row.Field <string>("password"), }; return(user); } else { return(null); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Processes the activation key for user account creation. /// </summary> private void ProcessActivationKey() { var key = Utilities.GetQueryStringGuid("activationKey"); if (key == null) { return; } switch (UserUtilities.CheckActivateUser((Guid)key)) { case -1: { WriteFeedBackMaster(FeedbackType.Warning, "Invalid activation link."); } break; case 0: { WriteFeedBackMaster(FeedbackType.Warning, "User is already activate."); } break; case 1: { WriteFeedBackMaster(FeedbackType.Success, "Account activated successfully you may now login."); } break; } }
public void CheckPasswordComplexity() { Assert.IsTrue(UserUtilities.CheckPasswordComplexity("password123"), "Password complexity standards not correctly enforced."); Assert.IsFalse(UserUtilities.CheckPasswordComplexity("1234"), "Password complexity standards not correctly enforced."); Assert.IsFalse(UserUtilities.CheckPasswordComplexity("abc"), "Password complexity standards not correctly enforced."); Assert.IsFalse(UserUtilities.CheckPasswordComplexity("abc123"), "Password complexity standards not correctly enforced."); }
public async Task<ActionResult> UndoCorona([FromQuery] int userId) { User user = null; // You can only mark yourself as having corona if (UserUtilities.GetUserId(httpContextAccessor.HttpContext.User) != userId) { return Unauthorized(); } user = await DataAccess.Get<User, int>(userId); user.AtRisk = false; await user.UpdateAsync(); try { await VisitAccess.UpdateVisitStatus(userId, SqlConstants.DateTimeMin, false); } catch (Exception ex) { throw new Exception("Failed to update user as not having covid", ex); } return new OkResult(); }
/// <summary> /// Fixed: /// </summary> public string ChangePasswordAtLogin(Context context) { var log = new SysLogModel(context: context); var json = UserUtilities.ChangePasswordAtLogin(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
/// <summary> /// Fixed: /// </summary> public string ResetPassword(Context context, int id) { var log = new SysLogModel(context: context); var json = UserUtilities.ResetPassword(context: context, userId: id); log.Finish(context: context, responseSize: json.Length); return(json); }
public string GridRows() { var log = new SysLogModel(); var json = UserUtilities.GridRows(); log.Finish(json.Length); return(json); }
/// <summary> /// Fixed: /// </summary> public string Import(Context context, long id, IHttpPostedFile[] file) { var log = new SysLogModel(context: context); var json = UserUtilities.Import(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
public string SyncByLdap() { var log = new SysLogModel(); var json = UserUtilities.SyncByLdap(); log.Finish(json.Length); return(json); }
public string SyncByLdap(IContext context) { var log = new SysLogModel(context: context); var json = UserUtilities.SyncByLdap(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
public string ChangePasswordAtLogin() { var log = new SysLogModel(); var json = UserUtilities.ChangePasswordAtLogin(); log.Finish(json.Length); return(json); }
public string GridRows(Context context) { var log = new SysLogModel(context: context); var json = UserUtilities.GridRows(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
/// <summary> /// Fixed: /// </summary> public string ReturnOriginalUser(Context context) { var log = new SysLogModel(context: context); var json = UserUtilities.ReturnOriginalUser(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
/// <summary> /// Fixed: /// </summary> public string SetStartGuide(Context context) { var log = new SysLogModel(context: context); var json = UserUtilities.SetStartGuide(context: context); log.Finish(context: context, responseSize: json.Length); return(json); }
public string ResetPassword(int id) { var log = new SysLogModel(); var json = UserUtilities.ResetPassword(id); log.Finish(json.Length); return(json); }
public void AddUser() { UserRepository userRepository = new UserRepository(); string hashedPassword = UserUtilities.HashString("password123"); User newUser = userRepository.AddUser("*****@*****.**", hashedPassword, "Tester2"); ValidateUser(newUser); }
override protected void OnNavigatedTo(NavigationEventArgs e) { if (isCustomer) { // if we have a customer we need to load a bunch of info var db = new AirContext(); var user = db.Users.Include(dbuser => dbuser.CustInfo) .ThenInclude(custInfo => custInfo.Trips) .ThenInclude(trip => trip.Origin) .Include(user => user.CustInfo) .ThenInclude(custInfo => custInfo.Trips) .ThenInclude(trip => trip.Destination) .Include(user => user.CustInfo) .ThenInclude(custInfo => custInfo.Trips) .ThenInclude(trip => trip.Tickets) .ThenInclude(ticket => ticket.Flight) .ThenInclude(scheduledFlight => scheduledFlight.Flight) .ThenInclude(flight => flight.Origin) .Include(user => user.CustInfo) .ThenInclude(custInfo => custInfo.Trips) .ThenInclude(trip => trip.Tickets) .ThenInclude(ticket => ticket.Flight) .ThenInclude(scheduledFlight => scheduledFlight.Flight) .ThenInclude(flight => flight.Destination) .Single(dbuser => dbuser.UserId == UserSession.userId); CustomerInfo customerInfo = user.CustInfo; // award points for any trips that have departed & were not yet claimed int newPoints = 0; // loop through all of their trips foreach (Trip trip in customerInfo.Trips) { // check if the trip has departed if (trip.GetFormattedDeparted() == "Trip has departed!") { // make sure they haven't claimed the points already if (!trip.PointsClaimed) { // Award the appropriate points to the user UserUtilities.AwardPoints(user, (trip.TotalCost / 100) * 10); newPoints = trip.TotalCost / 100; // keep track of this for the ui trip.PointsClaimed = true; // set the points claimed to true var dbtrip = db.Trips.Single(dbtripinterior => dbtripinterior.TripId == trip.TripId); dbtrip.PointsClaimed = true; // and update the db as well db.SaveChanges(); } } } // Display basic info about the user WelcomeText.Text = $"Welcome back {customerInfo.Name}!"; PointsText.Text = $"You currently have {customerInfo.PointsAvailable + newPoints} points available, and overall you have used {customerInfo.PointsUsed} points."; CreditText.Text = $"You currently have a credit balance of ${customerInfo.CreditBalance / 100} with us."; TicketSummaryText.Text = $"You have booked {customerInfo.Trips.ToArray().Length} trips with us."; // and fill our list view with the customers trips TripList.ItemsSource = customerInfo.Trips; } }
//Main entry point of program. Set up of database / business logic layer can be added here static void Main() { //check to see if stock API key is set up if (ConfigurationManager.AppSettings["BarchartKey"] == null || ConfigurationManager.AppSettings["BarchartKey"] == "" || ConfigurationManager.AppSettings["BarchartKey"] == "KEY GOES HERE") { Console.WriteLine("The Barchart API key could not be found, please enter the key into the 'keys.config' file"); Console.WriteLine("For developers the keys.config file can be found in the google drive"); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } //startup the DB UserUtilities.StartupDB(); int port = 9000; string baseAddress = "http://*:" + port; //NOTE: If get error here, need to run either the application / visual studio in //administrator mode, due to listening to all addresses. Furthermore if having issue connecting //to this server from an outside computer make sure windows firewall has the desired port on an inbound rule, //also make sure the router has forwarded the port to the host machine try { using (WebApp.Start <Startup>(url: baseAddress)) { Console.WriteLine("Server Started up on port " + port); Console.WriteLine("Enter a command. type 'help' for a list of commands"); bool keep = true; while (keep) { string command = Console.ReadLine(); switch (command) { case "help": Console.WriteLine("'help' - Displays this message"); Console.WriteLine("'exit' - Exits the server"); Console.WriteLine("'email' - Sends out an email blast to those who have subscribed"); break; case "exit": Console.WriteLine("exiting..."); keep = false; break; case "email": UserUtilities.emailAll(); Console.WriteLine("All mail entries have been sent."); break; default: Console.WriteLine("Command not recongnized. Please try again"); break; } } } } //Catch the error that is thrown when admin mode requirement is not met catch (TargetInvocationException e) { Console.WriteLine("Please run the application in administrator mode."); Console.WriteLine("Alternatively, run 'allowFirewall.cmd' in adminstrator mode to allow connection"); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } }