public ActionResult LogOnKnownUser(RoomBookingViewModel model, string returnUrl, string signIn) { if (ModelState.IsValid) { bool guestLogin; if (AppSecurity.Login(model.UserName, model.Password, out guestLogin)) { //CreateShift(model.UserName, model.Password); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin })); } ModelState.AddModelError("", "The user name or password provided is incorrect."); } // If we got this far, something failed, redisplay form model.ErrorMessage = "Log in Failed. Incorrect user credentials"; return(RedirectToAction("Index", "Home", new { loginFailed = true })); }
public LoginViewModel() { LoginCommand = new DelegateCommand((_) => { if (string.IsNullOrWhiteSpace(UserName)) { ShowMessage("The user name is required and cannot be empty"); return; } if (string.IsNullOrWhiteSpace(Password)) { ShowMessage("The password is required and cannot be empty"); return; } if (AppSecurity.Login(UserName, Password, out string errorMessage)) { DialogResult = true; } else { ShowMessage(errorMessage); } }); ExitCommand = new DelegateCommand((_) => { DialogResult = false; }); }
public ActionResult LogOn(RoomBookingViewModel model, string returnUrl, string signIn) { // return View("_ErrorMessage", new BaseViewModel { Errormsg = "AdminLogOn LoginSucessful.. Redirecting....." }); if (signIn == "Create Account") { Mapper.CreateMap <Person, PersonEmailViewModel>(); var gu = Guid.NewGuid().ToString(); var pvm = Mapper.Map <Person, PersonEmailViewModel>(new Person { BirthDate = DateTime.Today.AddYears(-20), PersonID = 0, StartDate = DateTime.Now, EndDate = DateTime.Now.AddMonths(1), FirstName = gu, LastName = gu, Address = gu, Title = "MM", MiddleName = gu, PersonTypeId = (int)PersonTypeEnum.Guest }); return(View("NewPerson", pvm)); } model.UserName = "******"; model.Password = "******"; if (ModelState.IsValid) { bool guestLogin; if (AppSecurity.Login(model.UserName, model.Password, out guestLogin)) { //CreateShift(model.UserName, model.Password); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin })); } ModelState.AddModelError("", "The user name or password provided is incorrect."); } // If we got this far, something failed, redisplay form model.ErrorMessage = "Log in Failed. Incorrect user credentials"; return(RedirectToAction("Index", "Home", new { loginFailed = true })); }
public ActionResult AdminLogOnPAYG(RoomBookingViewModel model, string returnUrl, string signIn) { if (string.IsNullOrEmpty(model.UserName)) { ModelState.AddModelError("", "The Pin Code entered is invalid."); } else { var guestCredential = AppSecurity.GetUserByPinCode(model.UserName); if (guestCredential == null) { ModelState.AddModelError("", "The Pin Code entered is invalid."); } else { if (guestCredential.EndDate < DateTime.Today) { ModelState.AddModelError("", "The Pin Code entered has expired."); } else { bool guestLogin; if (AppSecurity.Login(guestCredential.Person.Username, guestCredential.Person.Password, out guestLogin)) { if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } //var tt = GetName(); return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin, auth = "req" })); } //return View("_ErrorMessage", new BaseViewModel { Errormsg = "The user name or password provided is incorrect." }); ModelState.AddModelError("", "The user name or password provided is incorrect."); return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = true, auth = "req" })); } } } return(View("PAYGLogin", new BaseViewModel())); }
public ActionResult StaffLogOn(RoomBookingViewModel model, string returnUrl) { try { if (ModelState.IsValid) { bool guestLogin; if (AppSecurity.Login(model.UserName, model.Password, out guestLogin)) { if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } //var tt = GetName(); return(RedirectToAction("Index", "Home", new { model.UserName, guestLogin = guestLogin, auth = "req" })); } //return View("_ErrorMessage", new BaseViewModel { Errormsg = "The user name or password provided is incorrect." }); ModelState.AddModelError("", "The user name or password provided is incorrect."); } // If we got this far, something failed, redisplay form model.ErrorMessage = "Log in Failed. Incorrect user credentials"; model.Errormsg = "Log in Failed. Incorrect user credentials"; //return View("_ErrorMessage", new BaseViewModel { Errormsg = "Log in Failed. Incorrect user credentials" }); return(View("StaffLock", model)); } catch (Exception ex) { return(View("_ErrorMessage", new BaseViewModel { Errormsg = ex.Message })); } }
public async void OnLoginCommandClicked() { string message = ""; if (!IsValidated(out message)) { await DisplayAlert("Error", message); return; } IsBusy = true; var result = await App.AccountManager.GetTokenAsync(UserName, Password); if (!result.IsSuccess) { IsBusy = false; await DisplayAlert("Error", result.Message); return; } AppSecurity.Login(result.Data.Token, result.Data.ExpiryTime); // sendToken(); var resultUser = await App.AccountManager.GetMeAsync(); if (!resultUser.IsSuccess) { IsBusy = false; await DisplayAlert("Error", resultUser.Message); return; } AppSecurity.LoginUser(resultUser.Data); SaveOrUpdateUser(resultUser.Data); IsBusy = false; await new Views.UserListPage().SetItAsRootPageAsync(); }