/// <summary>
 /// 系统消息提示页面(登录时未激活、被封禁状态的提示页面)
 /// </summary>
 /// <returns></returns>
 public string SystemMessage(TempDataDictionary tempData = null, SystemMessageViewModel model = null, string returnUrl = null)
 {
     if (tempData != null && model != null)
     {
         //tempData.Remove("SystemMessageViewModel");
         tempData["SystemMessageViewModel"] = model;
     }
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     if (!string.IsNullOrEmpty(returnUrl))
         routeValueDictionary.Add("returnUrl", WebUtility.UrlEncode(returnUrl));
     return CachedUrlHelper.Action("SystemMessage", "Account", CommonAreaName, routeValueDictionary);
 }
        public ActionResult Edit(BarThreadEditModel barThreadEditModel)
        {
            SystemMessageViewModel message = new SystemMessageViewModel
            {
                Title = "发帖失败了!",
                Body = "发帖失败,请稍后再试!",
                StatusMessageType = StatusMessageType.Hint
            };

            string errorMessage = string.Empty;
            if (ModelState.HasBannedWord(out errorMessage))
            {
                message.Body = errorMessage;
                return Redirect(SiteUrls.Instance().SystemMessage(TempData, message, Request.RawUrl));
            }

            if (barThreadEditModel.ThreadId > 0)
            {
                if (authorizer.BarThread_Edit(barThreadEditModel.AsBarThread()))
                {
                    BarThread thread = barThreadEditModel.AsBarThread();
                    //编辑方法
                    barThreadService.Update(thread, UserContext.CurrentUser.UserId);
                    long groupId = Request.Form.Get<long>("BarThreadCategory", 0);
                    categoryService.ClearCategoriesFromItem(barThreadEditModel.ThreadId, barThreadEditModel.SectionId, TenantTypeIds.Instance().BarThread());
                    if (groupId > 0)
                        categoryService.AddCategoriesToItem(new List<long> { groupId }, barThreadEditModel.ThreadId);
                    tagService.ClearTagsFromItem(barThreadEditModel.ThreadId, barThreadEditModel.SectionId);
                    string tags = string.Join(",", barThreadEditModel.TagNames);
                    tagService.AddTagsToItem(tags, barThreadEditModel.SectionId, barThreadEditModel.ThreadId);
                    IBarUrlGetter getter = BarUrlGetterFactory.Get(thread.TenantTypeId);
                    return Redirect(getter.ThreadDetail(thread.ThreadId));
                }
                else
                {
                    message.Title = "编辑帖子失败!";
                    message.Body = "您没有权限编辑帖子!";
                }
            }
            else
            {
                if (authorizer.BarThread_Create(barThreadEditModel.SectionId, out errorMessage))
                {
                    //新建方法
                    BarThread barThread = barThreadEditModel.AsBarThread();
                    bool isCreated = barThreadService.Create(barThread);
                    if (isCreated)
                    {
                        long groupId = Request.Form.Get<long>("BarThreadCategory", 0);
                        if (groupId > 0)
                            categoryService.AddCategoriesToItem(new List<long> { groupId }, barThread.ThreadId);
                        string tags = string.Join(",", barThreadEditModel.TagNames);

                        tagService.AddTagsToItem(tags, barThread.SectionId, barThread.ThreadId);

                        IBarUrlGetter getter = BarUrlGetterFactory.Get(barThread.TenantTypeId);
                        return Redirect(getter.ThreadDetail(barThread.ThreadId));
                    }
                }
                else
                {
                    message.Body = errorMessage;
                }
            }
            return Redirect(SiteUrls.Instance().SystemMessage(TempData, message, Request.RawUrl));
        }
Exemplo n.º 3
0
 public ActionResult Invite(string invite)
 {
     InvitationCode invitationCode = inviteFriendService.GetInvitationCodeEntity(invite);
     if (invitationCode == null || invitationCode.ExpiredDate.CompareTo(DateTime.UtcNow) < 0)
     {
         return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
         {
             Title = "链接失效",
             Body = "邀请链接已经过期",
             StatusMessageType = StatusMessageType.Hint
         }));
     }
     IUser user = authenticationService.GetAuthenticatedUser();
     if (user == null)
     {
         HttpCookie httpCookie = new System.Web.HttpCookie("invite", invite);
         httpCookie.Expires = DateTime.Now.AddHours(0.16);
         Response.Cookies.Add(httpCookie);
         return Redirect(SiteUrls.Instance().Register());
     }
     string errorMessage;
     bool canFollow = CanFollowUser(user.UserId, invitationCode.UserId, out errorMessage);
     if (canFollow)
     {
         string token = Utility.EncryptTokenForInviteFriend(0.01, user.UserId);
         return Redirect(SiteUrls.Instance().ConfirmFollow(token, invitationCode.Code));
     }
     else
     {
         TempData["SystemMessageViewModel"] = new SystemMessageViewModel
         {
             Title = "确认失败",
             Body = errorMessage,
             StatusMessageType = StatusMessageType.Hint
         };
         return Redirect(SiteUrls.Instance().SystemMessage());
     }
 }
Exemplo n.º 4
0
        public ActionResult ActivateEmail(string token)
        {
            bool isTimeout = false;
            long userId = Utility.DecryptTokenForValidateEmail(token, out isTimeout);
            SystemMessageViewModel model = null;
            if (!isTimeout)
            {
                if (!(userId > 0))
                    return Redirect(SiteUrls.Instance().SystemMessage());
                if (userSettings.AccountActivation == AccountActivation.Automatic || userSettings.AccountActivation == AccountActivation.Email)
                    membershipService.ActivateUsers(new List<long> { userId });
                userService.UserEmailVerified(userId);
                IUser user = userService.GetUser(userId);
                string title = string.Empty;
                if (user.IsActivated)
                    title = "帐号丶邮箱";
                else
                    title = "邮箱";
                model = new SystemMessageViewModel
                  {
                      StatusMessageType = StatusMessageType.Success,
                      Title = string.Format("{0}通过验证", title),
                      Body = string.Format("您的{0}已经通过验证,以后可以通过邮箱登录您的帐号", title)
                  };
                authenticationService.SignIn(user, false);

            }
            return Redirect(SiteUrls.Instance().SystemMessage(TempData, model));
        }
Exemplo n.º 5
0
 /// <summary>
 /// 邀请注册的对应处理代码
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 private bool InviteRegister(out SystemMessageViewModel message)
 {
     message = new SystemMessageViewModel
     {
         Title = "不允许注册",
         Body = "站点现在不允许注册,请联系管理员,索要帐号",
         StatusMessageType = StatusMessageType.Hint
     };
     if (userSettings.RegistrationMode == RegistrationMode.All)
         return true;
     if (userSettings.RegistrationMode == RegistrationMode.Disabled)
         return false;
     message = new SystemMessageViewModel
     {
         Title = "邀请注册",
         Body = "站点开启了邀请注册,只有在拥有邀请码的情况才允许注册",
         StatusMessageType = StatusMessageType.Hint
     };
     if (Request.Cookies["invite"] == null)
         return false;
     InvitationCode code = inviteFriendService.GetInvitationCodeEntity(Request.Cookies["invite"].Value);
     if (code == null || code.ExpiredDate.CompareTo(DateTime.UtcNow) < 0)
     {
         message = new SystemMessageViewModel
         {
             Body = "您的邀请码已经过期了!",
             StatusMessageType = StatusMessageType.Hint
         };
         return false;
     }
     return true;
 }
Exemplo n.º 6
0
        public ActionResult SystemMessage(string returnUrl = null)
        {
            if (TempData["SystemMessageViewModel"] == null)
                TempData["SystemMessageViewModel"] = new SystemMessageViewModel
                {
                    Body = "您访问的页面已经失效",
                    ReturnUrl = returnUrl,
                    Title = "链接失效",
                    StatusMessageType = StatusMessageType.Hint
                };

            SystemMessageViewModel systemMessageViewModel = TempData["SystemMessageViewModel"] as SystemMessageViewModel;
            TempData["SystemMessageViewModel"] = systemMessageViewModel;
            pageResourceManager.InsertTitlePart(systemMessageViewModel.Title);
            systemMessageViewModel.ButtonLink.Clear();

            IUser iUser = authenticationService.GetAuthenticatedUser();

            if (string.IsNullOrEmpty(returnUrl) && Request.UrlReferrer != null && !string.IsNullOrEmpty(Request.UrlReferrer.AbsoluteUri))
                returnUrl = Request.UrlReferrer.AbsoluteUri;
            if (!string.IsNullOrEmpty(returnUrl))
            {
                if (!returnUrl.StartsWith("http", StringComparison.CurrentCultureIgnoreCase) && !returnUrl.StartsWith("javascript", StringComparison.CurrentCultureIgnoreCase))
                    systemMessageViewModel.ButtonLink.Add("返回上一页", returnUrl);
            }
            else if (iUser != null)
            {
                systemMessageViewModel.ButtonLink.Add("个人首页", SiteUrls.Instance().MyHome(iUser.UserId));
            }

            systemMessageViewModel.ButtonLink.Add("站点首页", SiteUrls.Instance().SiteHome());

            return View(systemMessageViewModel);
        }