Example #1
0
        private Boolean shouldApprove(IUser objUser)
        {
            User user = (User)objUser;

            if (SiteRole.IsInAdminGroup(user.RoleId))
            {
                return(false);
            }

            ContentSubmitter s = ContentSubmitter.find("User.Id=" + user.Id + " and AppId=" + ctx.app.Id).first();

            return(s == null);
        }
        public void CheckLogin()
        {
            if (SiteRole.IsInAdminGroup(ctx.viewer.obj.RoleId) == false)
            {
                echoRedirect(lang("exNoPermission"));
                return;
            }

            if (config.Instance.Site.LoginNeedImgValidation)
            {
                if (Html.Captcha.CheckError(ctx))
                {
                    run(Login);
                    return;
                }
            }

            String name = ctx.Post("Name");
            String pwd  = ctx.Post("Password1");

            if (ctx.viewer.obj.Name.Equals(name) == false || userService.IsNamePwdCorrect(name, pwd) == null)
            {
                errors.Add(lang("exUserNamePwdError"));
            }

            if (ctx.HasErrors)
            {
                logService.Add((User)ctx.viewer.obj, SiteLogString.LoginError(), ctx.Ip, SiteLogCategory.Login);
                run(Login);
                return;
            }

            AdminSecurityUtils.SetSession(ctx);
            logService.Add((User)ctx.viewer.obj, SiteLogString.LoginOk(), ctx.Ip, SiteLogCategory.Login);

            String returnUrl = ctx.Post("returnUrl");

            returnUrl = returnUrl.Replace("&", "&");
            if (strUtil.IsNullOrEmpty(returnUrl))
            {
                //redirectUrl( t2( new DashboardController().Index ) );
                redirectUrl(t2(Welcome));
            }
            else
            {
                redirectUrl(returnUrl);
            }
        }
Example #3
0
        private String getLoginJsonString()
        {
            User user = ctx.viewer.obj as User;

            Boolean isViewerOwnerSame = (ctx.owner.Id == ctx.viewer.Id && ctx.owner.obj.GetType() == ctx.viewer.obj.GetType());
            Boolean isAlertActivation = config.Instance.Site.EnableEmail && config.Instance.Site.AlertActivation;

            Dictionary <String, object> dic = new Dictionary <string, object>();

            Dictionary <String, object> viewer = new Dictionary <string, object>();

            viewer.Add("Id", user.Id);
            viewer.Add("IsLogin", ctx.viewer.IsLogin);
            viewer.Add("IsAdministrator", ctx.viewer.IsAdministrator());
            viewer.Add("IsInAdminGroup", SiteRole.IsInAdminGroup(ctx.viewer.obj.RoleId));
            viewer.Add("HasPic", user.HasUploadPic());
            viewer.Add("EmailConfirm", user.IsEmailConfirmed == 1);
            viewer.Add("IsAlertActivation", isAlertActivation);
            viewer.Add("IsAlertUserPic", config.Instance.Site.AlertUserPic);

            Dictionary <String, object> objViewer = new Dictionary <string, object>();

            objViewer.Add("Id", user.Id);
            objViewer.Add("Name", user.Name);
            objViewer.Add("FriendlyUrl", user.Url);
            objViewer.Add("Url", Link.ToMember(user));
            objViewer.Add("PicMedium", user.PicMedium);

            viewer.Add("obj", objViewer);

            dic.Add("viewer", viewer);
            dic.Add("viewerOwnerSame", isViewerOwnerSame);

            Dictionary <String, object> owner = new Dictionary <string, object>();

            owner.Add("IsSite", ctx.owner.obj.GetType() == typeof(Site));
            owner.Add("Id", ctx.owner.Id);

            dic.Add("owner", owner);
            dic.Add("navInfo", loginNavInfo());
            dic.Add("online", getOnlineDic());

            return(JsonString.Convert(dic));
        }
Example #4
0
        private String getAdminCmd()
        {
            String siteAdminCmd = "";

            if (SiteRole.IsInAdminGroup(ctx.viewer.obj.RoleId))
            {
                String lk = string.Format("<img src=\"{0}lock.gif\"/> ", sys.Path.Img);

                siteAdminCmd += string.Format("<a href=\"{0}\" class=\"quickCmd\">采集</a> ", Link.T2(ctx.viewer.obj, new Users.Admin.Spiders.ArticleController().List, 0));

                if (AdminSecurityUtils.HasSession(ctx))
                {
                    siteAdminCmd += string.Format("<a href='{0}'>{2}{1}</a>", Link.T2(Site.Instance, new Admin.MainController().Welcome), lang("siteAdmin"), lk);
                }
                else
                {
                    siteAdminCmd += string.Format("<a href='{0}'>{2}{1}</a>", Link.T2(Site.Instance, new Admin.MainController().Login), lang("siteAdmin"), lk);
                }
            }
            return(siteAdminCmd);
        }
Example #5
0
        private String getRoleName(int submitCount)
        {
            ContentApp           app = ctx.app.obj as ContentApp;
            ContentSubmitterRole sr  = app.GetSubmitterRoleObj();

            if (SiteRole.IsInAdminGroup(ctx.viewer.obj.RoleId))
            {
                return(sr.Editor);
            }

            ContentSubmitter s = ContentSubmitter.find("User.Id=" + ctx.viewer.Id + " and AppId=" + ctx.app.Id).first();

            if (s != null)
            {
                return(sr.getName(s.RoleId));
            }

            if (submitCount > 0)
            {
                return(sr.NeedApproval);
            }

            return("无");
        }