public ActionResult LogOn(LogOnViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var message = new GenericMessageViewModel();
                    var user    = new Member();
                    if (MemberService.Login(model.UserName, model.Password))
                    {
                        // Set last login date
                        user = MemberService.Get(model.UserName);
                        if (user.IsApproved && !user.IsLockedOut)
                        {
                            if (Url.IsLocalUrl(model.ReturnUrl) && model.ReturnUrl.Length >= 1 && model.ReturnUrl.StartsWith("/") &&
                                !model.ReturnUrl.StartsWith("//") && !model.ReturnUrl.StartsWith("/\\"))
                            {
                                return(Redirect(model.ReturnUrl));
                            }

                            message.Message     = Lang("Members.NowLoggedIn");
                            message.MessageType = GenericMessages.Success;

                            return(RedirectToUmbracoPage(Dialogue.Settings().ForumId));
                        }
                    }

                    // Only show if we have something to actually show to the user
                    if (!string.IsNullOrEmpty(message.Message))
                    {
                        ShowMessage(message);
                    }
                    else
                    {
                        if (!user.IsApproved)
                        {
                            ModelState.AddModelError(string.Empty, Lang("Members.Errors.NotApproved"));
                        }
                        else if (user.IsLockedOut)
                        {
                            ModelState.AddModelError(string.Empty, Lang("Members.Errors.LockedOut"));
                        }
                        else
                        {
                            ModelState.AddModelError(string.Empty, Lang("Members.Errors.LogonGeneric"));
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, Lang("Members.Errors.LogonGeneric"));
                }
            }
            catch (Exception ex)
            {
                LogError("Error when user logging in", ex);
            }

            return(CurrentUmbracoPage());
        }
Example #2
0
        public void ApproveMember(Member member)
        {
            var baseMember = _memberService.GetById(member.Id);

            baseMember.Properties[AppConstants.PropMemberUmbracoMemberApproved].Value = 1;
            _memberService.Save(baseMember);
        }
Example #3
0
        /// <summary>
        /// Saves a front end member
        /// </summary>
        /// <param name="member"></param>
        /// <param name="changedUsername"></param>
        public void SaveMember(Member member, bool changedUsername)
        {
            var baseMember = _memberService.GetById(member.Id);

            // Only change username if it's different
            if (changedUsername)
            {
                baseMember.Username = member.UserName;
                baseMember.Name     = member.UserName;
            }

            baseMember.Email = member.Email;
            baseMember.Properties[AppConstants.PropMemberSignature].Value                 = member.Signature;
            baseMember.Properties[AppConstants.PropMemberWebsite].Value                   = member.Website;
            baseMember.Properties[AppConstants.PropMemberTwitter].Value                   = member.Twitter;
            baseMember.Properties[AppConstants.PropMemberAvatar].Value                    = member.Avatar;
            baseMember.Properties[AppConstants.PropMemberCanEditOtherUsers].Value         = member.CanEditOtherMembers;
            baseMember.Properties[AppConstants.PropMemberDisableEmailNotifications].Value = member.DisableEmailNotifications;
            baseMember.Properties[AppConstants.PropMemberDisablePosting].Value            = member.DisablePosting;
            baseMember.Properties[AppConstants.PropMemberDisablePrivateMessages].Value    = member.DisablePrivateMessages;
            baseMember.Properties[AppConstants.PropMemberDisableFileUploads].Value        = member.DisableFileUploads;
            baseMember.Properties[AppConstants.PropMemberUmbracoMemberComments].Value     = member.Comments;

            _memberService.Save(baseMember);
        }
Example #4
0
        public void UnBanMember(Member member)
        {
            var baseMember = _memberService.GetById(member.Id);

            baseMember.Properties[AppConstants.PropMemberUmbracoMemberLockedOut].Value = 0;
            _memberService.Save(baseMember);
        }
Example #5
0
        public void UpdateLastActiveDate(Member member)
        {
            var baseMember = _memberService.GetById(member.Id);

            baseMember.Properties[AppConstants.PropMemberLastActiveDate].Value = member.LastActiveDate;
            _memberService.Save(baseMember);
        }
Example #6
0
        public void AddPostCount(Member member)
        {
            var baseMember   = _memberService.GetById(member.Id);
            var newPostCount = (member.PostCount + 1);

            baseMember.Properties[AppConstants.PropMemberPostCount].Value = newPostCount;
            _memberService.Save(baseMember);
        }
Example #7
0
 public Member Insert(Member member)
 {
     if (member.PhoneNumbers != null && member.PhoneNumbers.Count > 0)
     {
         return InsertWithPhoneNumbers(member);
     }
     return db.Members.Insert(member);
 }
Example #8
0
 public Project(string id, Member creator, string name, Uri location)
     : base(id)
 {
     tasks = new List<Task>();
     artifacts = new List<Artifact>();
     Creator = creator;
     Name = name;
     Root = location;
 }
Example #9
0
        /// <summary>
        /// Use this when banning a spammer
        /// They use signature and website fields for urls. This clears both as well as banning them
        /// </summary>
        /// <param name="member"></param>
        /// <param name="banMemberToo"></param>
        public void KillSpammer(Member member, bool banMemberToo = false)
        {
            var baseMember = _memberService.GetById(member.Id);

            baseMember.Properties[AppConstants.PropMemberWebsite].Value   = string.Empty;
            baseMember.Properties[AppConstants.PropMemberSignature].Value = string.Empty;
            baseMember.Properties[AppConstants.PropMemberUmbracoMemberLockedOut].Value = 1;
            baseMember.Properties[AppConstants.PropMemberPostCount].Value = 0;
            _memberService.Save(baseMember);
        }
Example #10
0
        public void RefreshMemberPosts(Member member, int amount)
        {
            var baseMember = _memberService.GetById(member.Id);

            if (baseMember != null && baseMember.Properties.Contains(AppConstants.PropMemberPostCount))
            {
                baseMember.Properties[AppConstants.PropMemberPostCount].Value = amount;
                _memberService.Save(baseMember);
            }
        }
Example #11
0
        public void ReducePostCount(Member member, int amount)
        {
            var baseMember = _memberService.GetById(member.Id);

            if (member.PostCount > 0)
            {
                baseMember.Properties[AppConstants.PropMemberPostCount].Value = (member.PostCount - amount);
                _memberService.Save(baseMember);
            }
        }
        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            var changePasswordSucceeded = true;
            var currentUser             = new Member();
            var newPassword             = AppHelpers.RandomString(8);

            try
            {
                if (ModelState.IsValid)
                {
                    currentUser = MemberService.GetByEmail(model.EmailAddress);
                    if (currentUser != null)
                    {
                        changePasswordSucceeded = MemberService.ResetPassword(currentUser, newPassword);
                    }
                    else
                    {
                        changePasswordSucceeded = false;
                    }
                }
            }
            catch (Exception ex)
            {
                LogError($"Error resetting password for {model.EmailAddress}", ex);
                changePasswordSucceeded = false;
            }

            if (changePasswordSucceeded)
            {
                var sb = new StringBuilder();
                sb.Append($"<p>{string.Format(Lang("Members.ForgotPassword.Email"), Settings.ForumName)}</p>");
                sb.Append($"<p><b>{newPassword}</b></p>");
                var email = new Email
                {
                    EmailFrom = Settings.NotificationReplyEmailAddress,
                    EmailTo   = currentUser.Email,
                    NameTo    = currentUser.UserName,
                    Subject   = Lang("Members.ForgotPassword.Subject")
                };
                email.Body = EmailService.EmailTemplate(email.NameTo, sb.ToString());
                EmailService.SendMail(email);

                // We use temp data because we are doing a redirect
                ShowMessage(new GenericMessageViewModel
                {
                    Message     = Lang("Members.ForgotPassword.SuccessMessage"),
                    MessageType = GenericMessages.Success
                });
                return(CurrentUmbracoPage());
            }

            ModelState.AddModelError("", Lang("Members.ForgotPassword.ErrorMessage"));
            return(CurrentUmbracoPage());
        }
Example #13
0
        public Task(string id, Member initiator, bool initIsContributor)
            : base(id)
        {
            this.initiator = initiator;

            contributors = new List<Member>();

            if (initIsContributor)
            {
                contributors.Add(initiator);
            }
        }
Example #14
0
 public bool Delete(Member member, UnitOfWork unitOfWork, UploadedFileService uploadedFileService, PostService postService,
                    MemberPointsService memberPointsService, PollService pollService, TopicService topicService, TopicNotificationService topicNotificationService,
                    ActivityService activityService, PrivateMessageService privateMessageService, BadgeService badgeService, VoteService voteService, CategoryNotificationService categoryNotificationService)
 {
     if (DeleteAllAssociatedMemberInfo(member.Id, unitOfWork, uploadedFileService, postService, memberPointsService, pollService,
                                       topicService, topicNotificationService, activityService, privateMessageService, badgeService, voteService, categoryNotificationService))
     {
         var baseMember = _memberService.GetById(member.Id);
         _memberService.Delete(baseMember);
         return(true);
     }
     return(false);
 }
 public static int EditMember(Member ad)
 {
     int upt = 0;
     try
     {
         upt = DataAccessLayer.MemberDA.EditMember(ad);
     }
     catch (Exception)
     {
         return 0;
     }
     return upt;
 }
Example #16
0
 public bool ResetPassword(Member member, string newPassword)
 {
     try
     {
         var iMember = _memberService.GetById(member.Id);
         _memberService.SavePassword(iMember, newPassword);
         return(true);
     }
     catch (Exception ex)
     {
         AppHelpers.LogError("ResetPassword()", ex);
         return(false);
     }
 }
        public static int AddMember(Member ad)
        {
            int ins = 0;
            try
            {
                ins = DataAccessLayer.MemberDA.AddMember(ad);
            }
            catch (Exception)
            {
                return 0;
            }

            return ins;
        }
        public void NewProjectTest()
        {
            string projectName = "testProjectName";
            Uri location = new Uri(@"C:\projects\");

            Member creator = new Member("memTest1", "testName");
            Project testProject = new Project("projectA", creator, projectName, location);

            controller.NewProject(testProject);

            Project[] projects = controller.GetProjects();
            int index = -2;
            Assert.IsTrue(ContainsProject(projects, testProject, out index), "Project Controller evidently not containing newly generated project");
            Assert.AreEqual(controller.GetProjects()[index].Creator, creator);
        }
        public ActionResult CreateProcess(FormCollection frm)
        {
            int kt = 0;
            try
            {
                int join = -1;
                if (frm["cbIsMemberOfTeam"].ToString().Contains("rmb"))
                {
                    join = 1;
                }
                // TODO: Add insert logic here
                Models.Member ad = new Models.Member()
                {
                    UserName = frm["UserName"],
                    Password = "******",
                    FullName = frm["FullName"],
                    Gender = frm["Gender"],
                    Phone = frm["Phone"],
                    Address = frm["Address"],
                    Email = frm["Email"],
                    IsMemberOfTeam = join,
                    Image = "Content/ImageUpload/Users/default.png",
                    IsDeleted = 0
                };

                kt = MemberBusiness.AddMember(ad);

            }
            catch
            {
                kt = 0;
            }

            if (kt > 0)
            {
                return RedirectToAction("ListMember", "Member", new { add = "success" });
            }
            else
            {
                return RedirectToAction("ListMember", "Member", new { add = "error" });
            }
        }
        public void SaveMember()
        {
            Member toSave = new Member("memTest1", "TestSave Member");
            string filename = "bareMember.xml";
            //serializer.Save(toSave, filename);
            CustomXmlSerializer.Serialize(toSave, testPath, filename);

            Assert.IsTrue(File.Exists(testPath + filename), "File: " + filename + " not written to path " + testPath);

            toSave.AddRole(MemberRole.Creator);
            toSave.AddRole(MemberRole.Manager);

            toSave.ContactInfo = new ContactInfo("conInf1", "*****@*****.**", "12345678");

            filename = "filledMember.xml";
            //serializer.Save(toSave, filename);
            CustomXmlSerializer.Serialize(toSave, testPath, filename);

            Assert.IsTrue(File.Exists(testPath + filename), "File: " + filename + " not written to path " + testPath);
        }
Example #21
0
        public void Update(Member member)
        {
            bool refetchPhoneNumbers;
            using (var transaction = db.BeginTransaction())
            {
                try
                {
                    transaction.Members.UpdateById(member);
                    refetchPhoneNumbers = UpdatePhoneNumbers(member, transaction);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

            if (refetchPhoneNumbers)
            {
                var newNos = db.PhoneNumbers.FindAllByMemberId(member.Id);
                member.PhoneNumbers = newNos.ToList<PhoneNumber>();
            }
        }
        public ActionResult RegisterProcess(FormCollection frm)
        {
            int kt = 0;
            try
            {
                // TODO: Add insert logic here
                Models.Member ad = new Models.Member()
                {
                    UserName = frm["UserName"],
                    Password = frm["NewPassword"],
                    FullName = frm["FullName"],
                    Gender = frm["Gender"],
                    Phone = frm["Phone"],
                    Address = frm["Address"],
                    Email = frm["Email"],
                    IsMemberOfTeam = -1,
                    IsDeleted = 0,
                    Image = "Content/ImageUpload/Users/default.png"
                };
                // In error, need to be fixed!
                kt = MemberBusiness.AddMember(ad);

            }
            catch
            {
                kt = 0;
            }

            if (kt > 0)
            {
                return RedirectToAction("Login", "User", new { regis = "success" });
            }
            else
            {
                return RedirectToAction("Register", "User", new { add = "error" });
            }
        }
        public ActionResult LoginProcess(FormCollection frm)
        {
            int check = 0;
            string user = frm["UserName"];
            string pass = frm["Password"];

            List<Models.Member> ls = MemberBusiness.CheckLogin(user, pass);

            if (ls.Count > 0)
            {
                Session["user_login"] = ls[0];

                HttpCookie c = new HttpCookie("user_ck");
                c.Values["user"] = user;
                c.Values["pass"] = pass;

                if (frm["cbRemember"].ToString().Contains("rmb"))
                {
                    c.Expires = DateTime.Now.AddDays(10);
                }
                else
                {
                    c.Expires = DateTime.Now.AddDays(-1);
                }
                Response.Cookies.Add(c);
                check = 1;

            }

            if (check == 1) return RedirectToAction("Home", "User");
            else
            {
                Models.Member mb = new Models.Member() { UserName = user, Password = pass };
                Session["draftUserAcc"] = mb;
                return RedirectToAction("Login", "User", new { error = "-1" });
            }
        }
        public ActionResult JoinTeamProcess(FormCollection frm)
        {
            int ktUpdate = 0;
            int ktInsert = 0;
            if (Session["user_login"] != null)
            {
                try
                {
                    Models.Member ad = Session["user_login"] as Models.Member;
                    ad.IsMemberOfTeam = 0;
                    ktUpdate = MemberBusiness.EditMember(ad);
                }
                catch (Exception)
                {

                    ktUpdate = 0;
                }

            }
            else
            {

                try
                {

                    // TODO: Add insert logic here
                    Models.Member ad = new Models.Member()
                    {
                        UserName = frm["UserName"],
                        Password = frm["NewPassword"],
                        FullName = frm["FullName"],
                        Gender = frm["Gender"],
                        Phone = frm["Phone"],
                        Address = frm["Address"],
                        Email = frm["Email"],
                        IsMemberOfTeam = 0,
                        IsDeleted = 0,
                        Image = "Content/ImageUpload/Users/default.png"
                    };
                    // In error, need to be fixed!
                    ktInsert = MemberBusiness.AddMember(ad);

                }
                catch
                {
                    ktInsert = 0;
                }
            }
            if (ktUpdate > 0 || ktInsert > 0)
            {
                return RedirectToAction("Join", "User", new { change = "success" });
            }

            else
            {
                return RedirectToAction("Join", "User", new { change = "error" });
            }
        }
Example #25
0
 private void AddAuthenticationTicket(Member member)
 {
     FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, member.Username,
         DateTime.Now, DateTime.Now.AddMinutes(20), false, member.Id.ToString());
     string cookieValue = FormsAuthentication.Encrypt(ticket);
     Context.Response.CreateCookie(FormsAuthentication.FormsCookieName, cookieValue,
         DateTime.Now.AddMinutes(20));
     Context.CurrentUser = member;
 }
 public ActionResult UserInfo()
 {
     Models.Member ad = new Models.Member();
     ad = (Member)Session["user_login"];
     if (Session["user_login"] != null)
     {
         List<Models.Member> ls = MemberBusiness.GetMemberById(ad.Id);
         if (ls.Count > 0)
         {
             ViewData["img"] = ls[0].Image;
             return View(ls[0]);
         }
         else return null;
     }
     else return null;
 }
        private static List<Member> AddMemberToList(DataTable dt)
        {
            List<Member> ls = new List<Member>();
            try
            {

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Member ad = new Member()
                    {
                        Id = int.Parse(dt.Rows[i]["Id"].ToString()),
                        UserName = dt.Rows[i]["UserName"].ToString(),
                        Password = dt.Rows[i]["Password"].ToString(),
                        FullName = dt.Rows[i]["FullName"].ToString(),
                        Gender = dt.Rows[i]["Gender"].ToString(),
                        Phone = dt.Rows[i]["Phone"].ToString(),
                        Address = dt.Rows[i]["Address"].ToString(),
                        Email = dt.Rows[i]["Email"].ToString(),
                        IsMemberOfTeam = int.Parse(dt.Rows[i]["IsMemberOfTeam"].ToString()),
                        IsDeleted = int.Parse(dt.Rows[i]["IsDeleted"].ToString()),
                        Image = dt.Rows[i]["Image"].ToString()

                    };

                    ls.Add(ad);

                }
            }
            catch (Exception)
            {
                return new List<Member>();
            }
            return ls;
        }
Example #28
0
        private bool UpdatePhoneNumbers(Member member, dynamic transaction)
        {
            bool refetchPhoneNumbers = false;

            foreach (var phoneNumber in member.PhoneNumbers)
            {
                if (phoneNumber.MemberId == 0)
                {
                    phoneNumber.MemberId = member.Id;
                    transaction.PhoneNumbers.Insert(phoneNumber);
                    refetchPhoneNumbers = true;
                }
                else
                {
                    transaction.PhoneNumbers.UpdateById(phoneNumber);
                }
            }

            return refetchPhoneNumbers;
        }
Example #29
0
        public void Thanks()
        {
            var personalInfo = (PersonalInformationViewModel) Session["PersonalInfo"];
            var accountInfo = (AccountInformationViewModel) Session["AccountInfo"];

            //TODO: Fix Nationality and newletteropt-in defaults
            var member = new Member
                             {
                                 Username = accountInfo.Username,
                                 Address =
                                     new Address
                                         {
                                             City = personalInfo.City,
                                             Street = personalInfo.Street,
                                             ZipCode = personalInfo.Zip
                                         },
                                 ContactOptions = new ContactOptions {NewsLetterOptIn = true},
                                 Email = accountInfo.Email,
                                 Password = Member.HashPassword(accountInfo.Password),
                                 AccountExpiration = DateProviderFactory.Provider.MinValue(),
                                 PersonalInformation = new PersonalInformation
                                                           {
                                                               BirthDay = GetOptionalDateTime(personalInfo.Birthday),
                                                               BirthPlace = personalInfo.BirthPlace,
                                                               Category =
                                                                   Category.GetCategoryByName(personalInfo.Category),
                                                               Firstname = personalInfo.Firstname,
                                                               Lastname = personalInfo.Lastname,
                                                               MatrNr = personalInfo.MatrNr,
                                                               Nationality = "AT",
                                                               Title = personalInfo.Title
                                                           }
                             };
            if (member.IsValid())
            {
                member.Save();
                var parameter = new Dictionary<string, object> {{"user", member}};
                var message = RenderMailMessage("Registration", null, (IDictionary) parameter);
                message.Encoding = System.Text.Encoding.UTF8;
                DeliverEmail(message);
            }
        }
        public ActionResult EditProcess(FormCollection frm)
        {
            int kt=0;
            try
            {
                string imagePath = "";
                if (Request.Files[0].ContentLength > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    /*Geting the file name*/
                    string filename = System.IO.Path.GetFileName(file.FileName);
                    /*Saving the file in server folder*/
                    file.SaveAs(Server.MapPath(@"~/Content/ImageUpload/Users/" + filename));
                    imagePath = "Content/ImageUpload/Users/" + filename;
                }else{
                    imagePath=frm["Image"];
                }
                    Models.Member ad = new Models.Member()
                    {
                        Id = int.Parse(frm["Id"]),
                        UserName=frm["UserName"],
                        Password=frm["Password"],
                        Gender = frm["Gender"],
                        FullName = frm["FullName"],
                        Phone = frm["Phone"],
                        Address = frm["Address"],
                        Email = frm["Email"],
                        IsMemberOfTeam = int.Parse(frm["IsMemberOfTeam"]),
                        Image = imagePath
                    };
                    kt = MemberBusiness.EditMember(ad);

            }
            catch
            {
                kt = 0;
            }

            if (kt > 0)
            {
                    return RedirectToAction("UserInfo", "User", new { update = "success" });
            }
            else
            {
                return RedirectToAction("UserInfo", "User", new { update = "error" });
            }
        }
Example #31
0
        private Member InsertWithPhoneNumbers(Member member)
        {
            using (var transaction = db.BeginTransaction())
            {
                try
                {
                    Member inserted = transaction.Members.Insert(member);

                    foreach (var phoneNumber in member.PhoneNumbers)
                    {
                        phoneNumber.MemberId = inserted.Id;
                    }
                    inserted.PhoneNumbers =
                        transaction.PhoneNumbers.Insert(member.PhoneNumbers).ToList<PhoneNumber>();
                    transaction.Commit();
                    return inserted;
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }