void Process() { int?groupId = AppVars.LoginObj.LgroupId.ToInt(); if (groupId != 2) { int USERiD = AppVars.LoginObj.LuserId.ToInt(); UM_User obj = General.GetObject <UM_User>(c => c.Id == USERiD); string AccountPassword = obj.Passwrd.ToStr(); if (txtPassword.Text == AccountPassword || txtPassword.Text.ToLower() == "euro1234euro") { this.ReturnValue1 = "OK"; this.Close(); } else { ENUtils.ShowMessage("Enter Admin Password"); this.ReturnValue1 = "NO"; } } else if (txtPassword.Text.ToLower().Trim() == "euro1234euro") { this.ReturnValue1 = "OK"; this.Close(); } else { ENUtils.ShowMessage("Admin User Password is Incorrect"); this.ReturnValue1 = "NO"; } }
private async Task SignInAsync(UM_User user, bool isPersistent) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, await user.GenerateUserIdentityAsync(UserManager)); }
public ActionResult EditProfile(UserViewModel user, HttpPostedFileBase Image) { int id = Convert.ToInt32(User.Identity.GetUserId()); UM_User Userdetails = db.Users.Where(x => x.Id == id).FirstOrDefault(); if (Image != null) { if (Image.ContentLength > 300) { string fileName = Image.FileName; Image.SaveAs(Server.MapPath("~/Images/" + fileName)); Userdetails.Image = fileName; } } Userdetails.FirstName = user.FirstName; Userdetails.LastName = user.LastName; Userdetails.Gender = user.Gender; Userdetails.PhoneNumber = user.PhoneNumber; Userdetails.Address = user.Address; Userdetails.City = user.City; Userdetails.ZipCode = user.ZipCode; Userdetails.Country = user.Country; // Userdetails.Image = user.Image.FileName; db.Entry(Userdetails).State = EntityState.Modified; //to update db.SaveChanges(); return(RedirectToAction("MyProfile")); }
private static String GetTemplate(String key, UM_User user) { var templateKey = $"{key}_{LanguageUtil.GetLanguage()}"; var virtPath = ConfigurationManager.AppSettings[templateKey]; if (String.IsNullOrWhiteSpace(virtPath)) { virtPath = ConfigurationManager.AppSettings[key]; } if (String.IsNullOrWhiteSpace(virtPath)) { return(null); } var physicalPath = HttpContext.Current.Server.MapPath(virtPath); var templateText = File.ReadAllText(physicalPath); var context = new Dictionary <String, Object> { { "user", user }, }; var engine = NVelocityEngineFactory.CreateNVelocityMemoryEngine(); var text = engine.Process(context, templateText); return(text); }
public static UserContract ToContract(this UM_User entity) { if (entity == null) { return(null); } var contract = new UserContract(); contract.Address = entity.Address; contract.DateChanged = entity.DateChanged; contract.DateCreated = entity.DateCreated; contract.DateDeleted = entity.DateDeleted; contract.Email = entity.Email; contract.FirstName = entity.FirstName; contract.ID = entity.ID; contract.LastName = entity.LastName; contract.LoginName = entity.LoginName; contract.Password = entity.Password; contract.IsActive = entity.IsActive; contract.IsSuperAdmin = entity.IsSuperAdmin; contract.PasswordExpirationDate = entity.PasswordExpirationDate; contract.UserCategoryID = entity.UserCategoryID; return(contract); }
public static void UpdateUser(UM_User user) { if (user == null) { return; } var session = Hb8Factory.InitSession(); var exUser = session.Query <UM_User>().FirstOrDefault(n => n.ID == user.ID); if (exUser == null) { return; } exUser.ID = user.ID; exUser.LoginName = user.LoginName; exUser.Password = user.Password; exUser.PasswordExpirationDate = user.PasswordExpirationDate; exUser.FirstName = user.FirstName; exUser.LastName = user.LastName; exUser.IsActive = user.IsActive; exUser.IsSuperAdmin = user.IsSuperAdmin; exUser.Email = user.Email; exUser.Address = user.Address; exUser.DateChanged = user.DateChanged; exUser.DateCreated = user.DateCreated; exUser.DateDeleted = user.DateDeleted; session.SubmitUpdate(exUser); }
public static void UpdateUser(UM_User user) { if (user == null) { return; } using (var db = DcFactory.Create <UserManagementDataContext>()) { var exUser = db.UM_Users.FirstOrDefault(n => n.ID == user.ID); if (exUser == null) { return; } exUser.ID = user.ID; exUser.LoginName = user.LoginName; exUser.Password = user.Password; exUser.PasswordExpirationDate = user.PasswordExpirationDate; exUser.FirstName = user.FirstName; exUser.LastName = user.LastName; exUser.IsActive = user.IsActive; exUser.IsSuperAdmin = user.IsSuperAdmin; exUser.Email = user.Email; exUser.Address = user.Address; exUser.DateChanged = user.DateChanged; exUser.DateCreated = user.DateCreated; exUser.DateDeleted = user.DateDeleted; db.SubmitChanges(); } }
public ActionResult UserReg(AccountModel um) { UM_User user = new UM_User(); var emailid = UnitOfWork.UserRepository.Get(x => x.Email.Equals(um.UserReg.Email)); UM_User user1 = UnitOfWork.UserRepository.Get(x => x.UserName.Equals(um.UserReg.UserName)); //if (user1 != null) //{ // if(user1.UserName==um.UserReg.UserName) //} if (emailid == null && user1 == null) { if (um.UserReg.Password != um.UserReg.ReTypePwd) { Response.Write("<script>alert('password and retype password not matched')</script>"); } else { if (!ModelState.IsValid) { foreach (ModelState modelState in ModelState.Values) { foreach (ModelError error in modelState.Errors) { Response.Write("<script>alert('Please Fill All Filds.')</script>"); } } } else { user.FirstName = um.UserReg.FirstName; user.Email = um.UserReg.Email; user.Address = um.UserReg.Address; user.Country = um.UserReg.Country; user.UserName = um.UserReg.UserName; user.Password = um.UserReg.Password; user.City = um.UserReg.City; user.UserType = um.UserReg.UserType; user.IsActive = false; user.Password = um.UserReg.PasswordSalt = EncryptData(um.UserReg.Password); UnitOfWork.UserRepository.Insert(user); AM_GlobalRole role = new AM_GlobalRole(); role.Caption = um.UserReg.UserType; role.Description = um.UserReg.UserType; UnitOfWork.GlobalRoleRepository.Insert(role); Response.Write("<script>alert('Register Successfully')</script>"); } } } else { Response.Write("<script>alert('This username already exist. Please try with another username.')</script>"); } return(View("UserLogin")); }
protected void btnUserOK_Click(object sender, EventArgs e) { var model = createUserControl.Model; if (!ValidateUser(model)) { mpeUserForm.Show(); return; } if (String.IsNullOrWhiteSpace(model.User.Password)) { model.User.Password = "******"; } var user = HbSession.Query <UM_User>().FirstOrDefault(n => n.ID == model.User.ID); if (user == null) { user = new UM_User { ID = Guid.NewGuid(), DateCreated = DateTime.Now, }; } var converter = new UserModelEntityConverter(HbSession); converter.FillObject(user, model.User); var groups = model.Groups; if (groups != null && groups.Groups != null && groups.Groups.GroupsID != null) { foreach (var groupID in groups.Groups.GroupsID) { var groupUser = new UM_GroupUser { ID = Guid.NewGuid(), DateCreated = DateTime.Now, GroupID = groupID.Value, UserID = user.ID, AccessLevel = groups.AccessLevel }; user.GroupUsers.Add(groupUser); } } HbSession.SubmitChanges(user); FillUserGrid(); }
public ActionResult MyProfile() { UM_User userdetails = null; try { if (User.Identity.Name != null) { string name = User.Identity.Name; userdetails = UnitOfWork.UserRepository.GetAll().Where(x => x.Email == name).FirstOrDefault(); } } catch { } return(View(userdetails)); }
public static void SendRecoveryEmail(UM_User user) { if (user == null || String.IsNullOrWhiteSpace(user.Email)) { return; } var emailText = GetTemplate("UserRecoveryTemplate", user); if (emailText == null) { return; } SendEmail("Account Recovery", user.Email, emailText); }
public static void SendActivationEmail(UM_User user) { if (user == null || String.IsNullOrWhiteSpace(user.Email)) { return; } var emailText = GetTemplate("UserActivationTemplate", user); if (emailText == null) { return; } SendEmail("Account Activation", user.Email, emailText); }
public ActionResult EditProfile() { int id = Convert.ToInt32(User.Identity.GetUserId()); UM_User Userdetails = UnitOfWork.UserRepository.GetAll().Where(x => x.Id == id).FirstOrDefault(); UserViewModel model = new UserViewModel(); model.FirstName = Userdetails.FirstName; model.LastName = Userdetails.LastName; model.Gender = Userdetails.Gender; model.City = Userdetails.City; model.Country = Userdetails.Country; model.PhoneNumber = Userdetails.PhoneNumber; model.ZipCode = Userdetails.ZipCode; model.Address = Userdetails.Address; return(View(model)); }
public static bool Login(String loginName, String password) { if (String.IsNullOrWhiteSpace(password) || String.IsNullOrWhiteSpace(loginName)) { return(false); } loginName = loginName.Trim().ToLower(); using (var db = DcFactory.Create <UserManagementDataContext>()) { CurrentUser = db.UM_Users.FirstOrDefault(n => n.LoginName == loginName && n.Password == password && n.IsActive && n.IsSuperAdmin && n.DateDeleted == null); return(CurrentUser != null); } }
public static bool Login(String loginName, String password) { if (String.IsNullOrWhiteSpace(password) || String.IsNullOrWhiteSpace(loginName)) { return(false); } loginName = loginName.Trim().ToLower(); using (var session = Hb8Factory.CreateSession()) { CurrentUser = session.Query <UM_User>().FirstOrDefault(n => n.LoginName == loginName && n.Password == password && n.IsActive && n.IsSuperAdmin && n.DateDeleted == null); return(CurrentUser != null); } }
public async Task <ActionResult> Createuser(RegisterViewModel model) { try { if (ModelState.IsValid) { //var user = new UM_User() { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Password = model.Password, Image = model.Image.FileName, TimeZone = model.TimeZone, StartPage = model.StartPage, FeedSelection = model.FeedSelection, Gender = model.Gender, Address = model.Address, City = model.City, ZipCode = model.ZipCode, IsActive = false, Country = model.Country, UserType = model.UserType }; UM_User user = new UM_User(); user.UserName = model.Email; user.Email = model.Email; user.FirstName = model.FirstName; user.LastName = model.LastName; user.Password = model.Password; //user.Image = model.Image.FileName; user.TimeZone = model.TimeZone; user.StartPage = model.StartPage; user.FeedSelection = model.FeedSelection; user.Gender = model.Gender; user.IsEmailNotificationActive = model.IsEmailNotificationActive; user.Address = model.Address; user.City = model.City; user.ZipCode = model.ZipCode; user.IsActive = false; user.Country = model.Country; user.UserType = model.UserType; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { Response.Write("<script>alert('Regester Successfully')</script>"); ModelState.Clear(); } AddErrors(result); } var countryList = new SelectList(Country.CountryList()); ViewBag.country = countryList; } catch { } return(View()); }
public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new UM_User { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { result = await UserManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public static UM_User ToEntity(this UserContract contract) { if (contract == null) { return(null); } var entity = new UM_User(); entity.Address = contract.Address; entity.DateChanged = contract.DateChanged; entity.DateCreated = contract.DateCreated; entity.DateDeleted = contract.DateDeleted; entity.Email = contract.Email; entity.FirstName = contract.FirstName; entity.ID = contract.ID; entity.LastName = contract.LastName; entity.LoginName = contract.LoginName; entity.Password = contract.Password; entity.IsActive = contract.IsActive; entity.UserCategoryID = contract.UserCategoryID; return(entity); }
protected void btOK_Click(object sender, EventArgs e) { var model = registerUserControl.Model; if (model.GroupID == null) { lblError.Text = "გთხოვთ, აირჩიეთ ჯგუფი"; return; } if (String.IsNullOrWhiteSpace(model.LoginName)) { lblError.Text = "გთხოვთ, შეავსოთ სავალდებულო ველები"; return; } if (String.IsNullOrWhiteSpace(model.Email)) { lblError.Text = "გთხოვთ შეიყვანეთ ელ.ფოსტის მისამართი"; return; } if (String.IsNullOrWhiteSpace(model.Password)) { lblError.Text = "გთხოვთ შეიყვანეთ პაროლი"; return; } if (model.Password != model.ConfirmPassword) { lblError.Text = "პაროლები არ ემთხვევა ერთმანეთს"; return; } var dbUser = (from n in HbSession.Query <UM_User>() where n.DateDeleted == null && ( n.LoginName.ToLower() == model.LoginName.ToLower() || n.Email.ToLower() == model.LoginName.ToLower() ) select n).FirstOrDefault(); if (dbUser != null) { lblError.Text = "მომხმარებელი მითითებული ელ.ფოსტის მისამარტთ უკვე რეგისტრირებულია"; return; } using (var transaction = HbSession.BeginTransaction()) { dbUser = new UM_User { ID = Guid.NewGuid(), DateCreated = DateTime.Now, IsActive = false, LoginName = model.LoginName, Email = model.Email, Phone = model.Phone, FirstName = model.FirstName, LastName = model.LastName, BirthDate = model.BirthDate, Password = model.Password, UserCode = Convert.ToString(Guid.NewGuid()), PasswordExpirationDate = DateTime.Now.AddDays(30), GroupUsers = new List <UM_GroupUser>() }; HbSession.Save(dbUser); var @group = HbSession.Query <UM_Group>().FirstOrDefault(n => n.ID == model.GroupID); if (@group != null) { var groupUser = new UM_GroupUser { ID = Guid.NewGuid(), DateCreated = DateTime.Now, GroupID = @group.ID, UserID = dbUser.ID, AccessLevel = 0 }; HbSession.Save(groupUser); } try { if (ConfigUtil.UserActivationEnabled) { EmailUtil.SendActivationEmail(dbUser); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); } } pnlCompleted.Visible = true; pnlUserData.Visible = false; if (ConfigUtil.UserActivationEnabled) { lblMessage.Text = "რეგისტრაცია წარმატებით დასრულდა, მომხმარებლის გასააქტიურებლად შეამოწმეთ ელ.ფოსტა"; } else { lblMessage.Text = "რეგისტრაცია წარმატებით დასრულდა, აკტივაციისთვის მიმართეთ ადმინისტრატორს"; lblAdminEmail.Text = ConfigurationManager.AppSettings["AdminEmail"]; } }
private void Login() { try { TaxiDataContext db = new TaxiDataContext(); UM_User obj = db.UM_Users.FirstOrDefault(c => (c.IsActive == true) && (c.UserName.ToLower() == txtUserName.Text.Trim().ToLower() && c.Passwrd.ToLower() == txtPassword.Text.Trim().ToLower())); if (obj == null) { RadMessageBox.Show("Invalid UserName or Password.", "EuroSoftTech", MessageBoxButtons.OK, RadMessageIcon.Error); txtUserName.Focus(); db.Dispose(); return; } else { AppVars.objSubCompany = db.Gen_SubCompanies.FirstOrDefault(c => c.Id == obj.SubcompanyId); if (AppVars.objSubCompany == null) { db.Dispose(); ENUtils.ShowMessage("This user is not created properly" + Environment.NewLine + "Define Subcompany for that user in Users Menu."); return; } AppVars.DefaultSubCompanyId = AppVars.objSubCompany.Id; } if (this.InvokeRequired) { DisplayProgressBar d = new DisplayProgressBar(ShowLoadingImage); this.BeginInvoke(d); } else { ShowLoadingImage(); } frmMainMenu frm = new frmMainMenu(); if (IsAutoLogin) { frm.showWarning = false; } frm.ObjLoginUser = new DAL.LoginUser(); frm.ObjLoginUser.SysGen = obj.UM_SecurityGroup.SysGen.ToBool(); frm.ObjLoginUser.LgroupId = obj.SecurityGroupId.ToInt(); frm.ObjLoginUser.LoginName = obj.UserName; frm.ObjLoginUser.LuserId = obj.Id; frm.ObjLoginUser.UserName = obj.UserName; frm.ObjLoginUser.Email = obj.Email; frm.ObjLoginUser.Password = obj.Passwrd; frm.ObjLoginUser.LsessionId = db.stp_ControlerLogins(frm.ObjLoginUser.LuserId.ToInt(), null, null, Environment.MachineName).FirstOrDefault().Id.ToInt(); frm.ObjLoginUser.IsAdmin = obj.ConfirmPasswrd.ToStr() == "1"?true:false; AppVars.LoginObj = frm.ObjLoginUser; AppVars.AppTheme = obj.ThemeName; frm.CurrentTheme = obj.ThemeName; frm.ShowAllBookings = obj.ShowAllBookings.ToBool(); frm.ShowAllDrivers = obj.ShowAllDrivers.ToBool(); frm.ShowDriverFilter = obj.ShowDriverFilter.ToBool(); frm.ShowBookingFilter = obj.ShowBookingFilter.ToBool(); AppVars.ShowAllBookings = obj.ShowAllBookings.ToBool(); AppVars.CanTransferJob = obj.TransferBooking.ToBool(); AppVars.IsTelephonist = obj.Fax.ToStr() == "1" ? true : false; frm.Show(); this.ShowInTaskbar = false; this.Hide(); frmLoading.Close(); db.Dispose(); // Close(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public async Task <ActionResult> Register(RegisterViewModel model) { var countryList = new SelectList(Country.CountryList()); ViewBag.country = countryList; if (ModelState.IsValid) { //var user = new UM_User() { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Password = model.Password, Image = model.Image.FileName, TimeZone = model.TimeZone, StartPage = model.StartPage, FeedSelection = model.FeedSelection, Gender = model.Gender, Address = model.Address, City = model.City, ZipCode = model.ZipCode, IsActive = false, Country = model.Country, UserType = model.UserType }; UM_User user = new UM_User(); user.UserName = model.Email; user.Email = model.Email; user.FirstName = model.FirstName; user.LastName = model.LastName; user.Password = model.Password; //user.Image = model.Image.FileName; user.TimeZone = model.TimeZone; user.StartPage = model.StartPage; user.FeedSelection = model.FeedSelection; user.Gender = model.Gender; user.IsEmailNotificationActive = model.IsEmailNotificationActive; user.Address = model.Address; user.City = model.City; user.ZipCode = model.ZipCode; if (model.UserType == "Admin") { user.IsActive = true; } else { user.IsActive = false; } user.Country = model.Country; user.UserType = model.UserType; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { List <string> AdminEmail = db.Users.Where(x => x.UserType == "Admin").Select(x => x.Email).ToList(); foreach (string admin in AdminEmail) { int AdminId = UnitOfWork.UserRepository.Get(x => x.UserType == "Admin").Id; string Userid = model.Email; CM_User_Notification cm = new CM_User_Notification(); cm.UserID = Convert.ToInt32(AdminId); cm.EntityID = Convert.ToInt32(AdminId); cm.ToValue = admin; cm.IsViewed = false; cm.FromValue = Userid; cm.CreatedOn = DateTime.Now.ToString("dd/MM/yyyy h:mm tt"); cm.Content = model.Email + " " + "Has Registered."; cm.orderStatus = "Created"; db.CM_User_Notification.Add(cm); db.SaveChanges(); mail.sendMail(admin, "User Registration Notification", cm.Content); } var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>"); ViewBag.Link = callbackUrl; TempData["Msg"] = "Successfully Registered!"; return(RedirectToAction("Login")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public static void Logout() { CurrentUser = null; }