public IActionResult OnPostSignIn() { if (ModelState.IsValid) { StreamingLiveLib.User user = StreamingLiveLib.User.Login(Email, Password); if (user == null) { ErrorMessage = "<div class=\"alert alert-warning\" role=\"alert\">Invalid email address / password combination.</div>"; } else { user.ResetGuid = Guid.NewGuid().ToString(); user.Save(); AppUser.Login(user); var claims = new[] { new Claim(ClaimTypes.Name, user.ResetGuid), new Claim(ClaimTypes.Role, "User") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); //***This doesn't seem like the right way to get the return url; if (ReturnUrl == null || ReturnUrl == "") { ReturnUrl = "/cp/"; } return(Redirect(ReturnUrl)); } } return(this.Page()); }
public ActionResult LoginAction() { string login = Request.Form["usernameLogin"]; string password = Request.Form["passwordLogin"]; int sessionId = AppUser.Login(login, password); if (sessionId == -1) { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Display", "Item", new { sessionId = sessionId })); }
protected void Button1_Click(object sender, EventArgs e) { AppUser user = AppUser.Login(this.userid.Value, this.pwd.Value); if (user.UserId > 0) { Response.Redirect("~/EventList.aspx"); } else { loginErrorMessage.Text = "You failed at hacking my site!!!!"; } }
private void LoginGuid() { StreamingLiveLib.User user = StreamingLiveLib.User.LoadByResetGuid(Request["guid"]); if (user == null) { OutputLit.Text = "<div class=\"alert alert-warning\" role=\"alert\">Invalid token. Please login or reset password again.</div>"; } else { AppUser.Login(user); FormsAuthentication.RedirectFromLoginPage(user.Email, false); } }
protected void Button1_Click(object sender, EventArgs e) { user = AppUser.Login(this.userid.Value, this.pwd.Value); if (user.UserId > 0) { Session["AppUser"] = user; Response.Redirect("~/EventList.aspx"); } else { loginErrorMessage.Text = "Failed to verify account."; } }
protected void SigninButton_Click(object sender, EventArgs e) { StreamingLiveLib.User user = StreamingLiveLib.User.Login(EmailText.Text, PasswordText.Text); if (user == null) { OutputLit.Text = "<div class=\"alert alert-warning\" role=\"alert\">Invalid email address / password combination.</div>"; } else { user.ResetGuid = Guid.NewGuid().ToString(); user.Save(); AppUser.Login(user); FormsAuthentication.RedirectFromLoginPage(user.ResetGuid, false); } }
public ActionResult Create() { string name = Request.Form["nameForm"]; string username = Request.Form["usernameForm"]; string password = Request.Form["passwordForm"]; string address = Request.Form["addressForm"]; string email = Request.Form["emailForm"]; AppUser newUser = new AppUser(name, username, password, address, email); if (newUser.Save()) { string login = username; int sessionId = AppUser.Login(login, password); return(RedirectToAction("Display", "Item", new { sessionId = sessionId })); } return(RedirectToAction("Form", new { sessionId = -1 })); }
public ActionResult ForgotAction(int sessionId) { string name = Request.Form["nameForgot"]; string username = Request.Form["usernameForgot"]; string email = Request.Form["emailForgot"]; int userId = AppUser.Forgot(name, username, email); if (userId == 0) { return(RedirectToAction("Forgot", new { sessionId = -1 })); } AppUser myUser = AppUser.Find(userId); sessionId = AppUser.Login(myUser.GetLogin(), myUser.GetPassword()); ViewBag.sessionId = sessionId; ViewBag.myUserName = myUser.GetName(); return(RedirectToAction("PasswordForm", new { sessionId = sessionId })); }
public async Task <AppUserModel> Login([FromBody] LoginObject login) { bool valid; HttpContext.Session.Clear(); valid = await AppUser.Login(contextProvider, login.email, login.password); if (!valid) { HttpContext.Session.Clear(); } else { CookiesHelper.WriteCookie(HttpContext, CookiesHelper.LoginCookieName, login.email, 1); } return((AppUserModel)(await contextProvider.GetAppUser()).ToModelObject); }
private async void SigninButton_Click(object sender, EventArgs e) { var email = emailEditText.Text; var password = passwordEditText.Text; var result = await AppUser.Login(email, password); if (result) { Toast.MakeText(this, "Welcome", ToastLength.Long).Show(); Intent intent = new Intent(this, typeof(TabsActivity)); StartActivity(intent); Finish(); } else { Toast.MakeText(this, "Try again later", ToastLength.Long).Show(); } }
private async void SigninButton_TouchUpInside(object sender, EventArgs e) { var email = emailTextField.Text; var password = passwordTextField.Text; UIAlertController alert = null; var result = await AppUser.Login(email, password); if (result) { alert = UIAlertController.Create("Success", "Welcome", UIAlertControllerStyle.Alert); } else { alert = UIAlertController.Create("Failure", "Couldn't log you in, please try again later", UIAlertControllerStyle.Alert); } alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); }
public IActionResult OnPostRegister() { if (ModelState.IsValid) { string[] errors = Validate(); if (errors.Length == 0) { string webRoot = CachedData.Environment.WebRootPath; StreamingLiveLib.Site s = new StreamingLiveLib.Site() { KeyName = KeyName.ToLower().Trim(), PrimaryColor = "#24b9ff", ContrastColor = "#ffffff", HeaderColor = "#24b9ff", HomePageUrl = "/", LogoUrl = "/data/master/logo.png", RegistrationDate = DateTime.UtcNow }; s.Save(); StreamingLiveLib.User u = new StreamingLiveLib.User() { Email = Email.ToLower().Trim(), Password = StreamingLiveLib.User.HashPassword(Password.Trim()), DisplayName = "Admin" }; u.ResetGuid = Guid.NewGuid().ToString(); u.Save(); StreamingLiveLib.Role r = new StreamingLiveLib.Role() { Name = "admin", SiteId = s.Id, UserId = u.Id }; r.Save(); new StreamingLiveLib.Button() { SiteId = s.Id, Sort = 1, Text = "Resources", Url = "about:blank" }.Save(); new StreamingLiveLib.Button() { SiteId = s.Id, Sort = 2, Text = "Give", Url = "about:blank" }.Save(); new StreamingLiveLib.Tab() { SiteId = s.Id, Sort = 1, TabType = "chat", TabData = "", Icon = "far fa-comment", Text = "Chat", Url = "" }.Save(); new StreamingLiveLib.Tab() { SiteId = s.Id, Sort = 2, TabType = "url", TabData = "", Icon = "fas fa-bible", Text = "Bible", Url = "https://www.bible.com/en-GB/bible/111/GEN.1.NIV" }.Save(); new StreamingLiveLib.Tab() { SiteId = s.Id, Sort = 3, TabType = "prayer", TabData = "", Icon = "fas fa-praying-hands", Text = "Prayer", Url = "" }.Save(); DateTime serviceTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9 + 5, 0, 0).AddDays(1); while (serviceTime.DayOfWeek != DayOfWeek.Sunday) { serviceTime = serviceTime.AddDays(1); } new StreamingLiveLib.Service() { SiteId = s.Id, ChatAfter = 15 * 60, ChatBefore = 15 * 60, Duration = 60 * 60, EarlyStart = 5 * 60, Provider = "youtube_watchparty", ProviderKey = "zFOfmAHFKNw", VideoUrl = "https://www.youtube.com/embed/zFOfmAHFKNw?autoplay=1&controls=0&showinfo=0&rel=0&modestbranding=1&disablekb=1", ServiceTime = serviceTime, TimezoneOffset = 300, Recurring = false }.Save(); Utils.CopyS3(S3Client, "data/master/data.json", $"data/{s.KeyName}/data.json"); Utils.CopyS3(S3Client, "data/master/data.css", $"data/{s.KeyName}/data.css"); try { string body = "<a href=\"https://" + s.KeyName + ".streaminglive.church/\">https://" + s.KeyName + ".streaminglive.church/</a> - " + u.Email; //StreamingLiveLib.Aws.EmailHelper.SendEmail(CachedData.SupportEmail, CachedData.SupportEmail, "New StreamingLive.church Registration", body); } catch { } AppUser.Login(u); var claims = new[] { new Claim(ClaimTypes.Name, u.ResetGuid), new Claim(ClaimTypes.Role, "User") }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); return(Redirect("/cp/")); } else { OutputMessage = Utils.FormatMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true); return(Page()); } } else { return(Page()); } }
protected void RegisterButton_Click(object sender, EventArgs e) { string[] errors = Validate(); if (errors.Length == 0) { StreamingLiveLib.Site s = new StreamingLiveLib.Site() { KeyName = KeyNameText.Text.ToLower().Trim(), PrimaryColor = "#24b9ff", ContrastColor = "#ffffff", HeaderColor = "#24b9ff", HomePageUrl = "/", LogoUrl = "/data/master/logo.png", RegistrationDate = DateTime.UtcNow }; s.Save(); StreamingLiveLib.User u = new StreamingLiveLib.User() { Email = EmailText.Text.ToLower().Trim(), Password = StreamingLiveLib.User.HashPassword(PasswordText.Text.Trim()), DisplayName = "Admin" }; u.ResetGuid = Guid.NewGuid().ToString(); u.Save(); StreamingLiveLib.Role r = new StreamingLiveLib.Role() { Name = "admin", SiteId = s.Id, UserId = u.Id }; r.Save(); new StreamingLiveLib.Button() { SiteId = s.Id, Sort = 1, Text = "Resources", Url = "about:blank" }.Save(); new StreamingLiveLib.Button() { SiteId = s.Id, Sort = 2, Text = "Give", Url = "about:blank" }.Save(); new StreamingLiveLib.Tab() { SiteId = s.Id, Sort = 1, TabType = "chat", TabData = "", Icon = "far fa-comment", Text = "Chat", Url = "" }.Save(); new StreamingLiveLib.Tab() { SiteId = s.Id, Sort = 2, TabType = "url", TabData = "", Icon = "fas fa-bible", Text = "Bible", Url = "https://www.bible.com/en-GB/bible/111/GEN.1.NIV" }.Save(); new StreamingLiveLib.Tab() { SiteId = s.Id, Sort = 3, TabType = "prayer", TabData = "", Icon = "fas fa-praying-hands", Text = "Prayer", Url = "" }.Save(); DateTime serviceTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9 + 5, 0, 0).AddDays(1); while (serviceTime.DayOfWeek != DayOfWeek.Sunday) { serviceTime = serviceTime.AddDays(1); } new StreamingLiveLib.Service() { SiteId = s.Id, ChatAfter = 15 * 60, ChatBefore = 15 * 60, Duration = 60 * 60, EarlyStart = 5 * 60, Provider = "youtube_watchparty", ProviderKey = "zFOfmAHFKNw", VideoUrl = "https://www.youtube.com/embed/zFOfmAHFKNw?autoplay=1&controls=0&showinfo=0&rel=0&modestbranding=1&disablekb=1", ServiceTime = serviceTime, TimezoneOffset = 300, Recurring = false }.Save(); System.IO.Directory.CreateDirectory(Server.MapPath("/data/" + s.KeyName)); System.IO.File.Copy(Server.MapPath("/data/master/data.json"), Server.MapPath("/data/" + s.KeyName + "/data.json")); System.IO.File.Copy(Server.MapPath("/data/master/data.css"), Server.MapPath("/data/" + s.KeyName + "/data.css")); try { string body = "<a href=\"https://" + s.KeyName + ".streaminglive.church/\">https://" + s.KeyName + ".streaminglive.church/</a> - " + u.Email; StreamingLiveLib.Aws.EmailHelper.SendEmail(CachedData.SupportEmail, CachedData.SupportEmail, "New StreamingLive.church Registration", body); } catch { } AppUser.Login(u); FormsAuthentication.SetAuthCookie(u.ResetGuid.ToString(), true); Response.Redirect("/cp/welcome.aspx"); } else { OutputMessage("<b>Error:</b><ul><li>" + String.Join("</li><li>", errors) + "</li></ul>", true, OutputLit); } }