public ResponseData ChangePassword(string accessKey, string password) { var response = new ResponseData(); var customerInfos = DayaxeDbContext.CustomerInfos.FirstOrDefault(x => x.ChangePasswordSessionId.Equals(accessKey)); if (customerInfos != null) { response.IsSuccessful = true; response.Message = new List <string> { customerInfos.EmailAddress, customerInfos.FirstName }; customerInfos.IsConfirmed = true; // customerInfos.ChangePasswordSessionId = string.Empty; //customerInfos.Password = password; customerInfos.Password = Algoritma.EncryptHMACSHA512(password, customerInfos.Salt); DayaxeDbContext.SubmitChanges(); } else { response.Message = new List <string> { "Your session has been expired" }; } return(response); }
protected void LoginClick(object sender, EventArgs e) { var user = _userRepository.GetUsersByEmail(Email.Text.Trim().ToUpper()); if (user != null) { if (user.Password == Algoritma.EncryptHMACSHA512(Password.Text, user.Salt)) { string json = JsonConvert.SerializeObject(user, CustomSettings.SerializerSettings()); Session["CurrentUser"] = json; if (Request.Params["ReturnUrl"] != null) { Response.Redirect(HttpUtility.UrlDecode(Request.Params["ReturnUrl"])); } Response.Redirect(Constant.HotelList); } } LblMessage.Text = "Please provide valid email and password"; }
protected void SaveUserClick(object sender, EventArgs e) { try { int userId = int.Parse(Request.Params["userId"]); string userName = TxtUsername.Text.Trim(); if (userId == 0) { if (string.IsNullOrEmpty(userName)) { LblMessage.Visible = true; LblMessage.Text = "Username is required"; return; } if (!Helper.IsValidEmail(userName)) { LblMessage.Visible = true; LblMessage.Text = "Please use valid email address"; return; } _users = _userRepository.GetCustomerByEmailAddress(userName); if (_users == null) { string salt = Algoritma.GenerateSalt(); string password = Algoritma.EncryptHMACSHA512("~new_dayaxe-user!", salt); _users = new CustomerInfos { FirstName = TxtFirstName.Text, LastName = TxtLastName.Text, EmailAddress = userName, Password = password, Salt = salt, CreatedDate = DateTime.UtcNow, IsActive = true, IsAdmin = true, IsCheckInOnly = DdlRole.SelectedValue == "3" // Checkin Only }; userId = _userRepository.Add(_users); } else { _users.FirstName = TxtFirstName.Text; _users.LastName = TxtLastName.Text; _users.EmailAddress = userName; _users.IsActive = true; _users.IsAdmin = true; _users.IsDelete = false; _users.IsCheckInOnly = DdlRole.SelectedValue == "3"; // Checkin Only _userRepository.Update(_users); userId = _users.CustomerId; } } else { _users = _userRepository.GetById(userId); _users.FirstName = TxtFirstName.Text; _users.LastName = TxtLastName.Text; _users.EmailAddress = userName; _users.IsCheckInOnly = DdlRole.SelectedValue == "3"; // Checkin Only _userRepository.Update(_users); } _userHotelRepository.ResetCache(); Response.Redirect(Constant.UserHotelPage + "?userId=" + userId); } catch (Exception ex) { LblMessage.Visible = true; LblMessage.Text = ex.Message; return; } }