public IActionResult Details(int id) { if (checkUserPermissionToApp.Invoke(LoggedUser.UserModel.Id, id)) { Breadcrumb.Add("Application details", "Details", "Application"); var app = getApp.Invoke(id); if (app == null) { return(View("Error")); } var appModel = new AppViewModel { Id = app.Id, Name = app.Name }; var listUsers = ListUsers(id); var combinedModel = new CombinedAppUserDetailsViewModel(appModel) { Users = listUsers }; return(View(combinedModel)); } Alert.Danger("You don't have permission!"); return(RedirectToAction("Index")); }
public IActionResult AddUser(int appId) { Breadcrumb.Add("Add user", "AddUser", "Application"); ViewData["appId"] = appId; return(View("AddUser")); }
public IActionResult Add() { Breadcrumb.Add("Add application", "Add", "Application"); var model = new AppViewModel(); return(View(new FormModel <AppViewModel>(model, true))); }
public IActionResult Login(string returnUrl) { if (LoggedUser != null) { return(RedirectToAction("Index", "Home")); } Breadcrumb.Add("Login", "Login", "Auth"); ViewBag.ReturnUrl = returnUrl; return(View()); }
public IActionResult Me() { Breadcrumb.Add("Your account", "Me", "User"); var model = LoggedUser.UserModel; var viewModel = new EditUserDetailsViewModel() { Name = model.Name, Email = model.Email }; return(View(new FormModel <EditUserDetailsViewModel>(viewModel))); }
public IActionResult ChangeUserRole(int appId, int userId) { Breadcrumb.Add("Change user role", "ChangeUserRole", "Application"); var userRole = getUserRole.Invoke(appId, userId); var model = new AppUserViewModel() { AppId = appId, UserId = userId, Role = userRole }; return(View(model)); }
public IActionResult Login(LoginModel model, string returnUrl) { Breadcrumb.Add("Login", "Login", "Auth"); if (!ModelState.IsValid) { logger.Information("Model is not valid"); Alert.Warning(); ViewBag.ReturnUrl = returnUrl; return(View(model)); } var handler = new ApiHelper(Settings.ApiReference); var resultString = handler.AcquireToken(model.Email, model.Password, "1"); var result = JsonConvert.DeserializeObject <ResultModel <object> >(resultString.ResponseMessage); if (result.Status.Code == ResultCode.Error) { ModelState.AddModelError("Email", "Invalid email or password"); logger.Information("Token is not valid"); Alert.Warning(); ViewBag.ReturnUrl = returnUrl; return(View(model)); } HttpContext.Session.SetString("token", result.Value.ToString()); var userDetails = getUserDetails.Invoke(model.Email); HttpContext.Session.SetString("UserDetails", JsonConvert.SerializeObject(userDetails)); ViewData["Message"] = model.Email; Alert.Success("Logged in"); if (string.IsNullOrEmpty(returnUrl)) { return(RedirectToAction("Index", "Home")); } return(Redirect(returnUrl)); }
public IActionResult Edit(int id) { if (checkUserPermissionToApp.Invoke(LoggedUser.UserModel.Id, id, ActionType.Edit)) { Breadcrumb.Add("Edit application", "Edit", "Application"); var app = getApp.Invoke(id); var model = new AppViewModel { Id = app.Id, Name = app.Name }; return(View(new FormModel <AppViewModel>(model, true))); } Alert.Danger("You don't have permission!"); return(RedirectToAction("Index")); }
public ApplicationController( IDeleteUser deleteUser, IGetAllUsers getAllUsers, IGetAppUsers getAppUsers, IGetAppUserRole getUserRole, IRevokeRole revokeRole, IGrantRole grantRole, IDeleteUserApp deleteUserApp, IAddNewUserApp addUserApp, IGetUserApps getUserApps, IOptions <ManagerSettings> managerSettings, IOptions <LoggerConfig> loggerSettings, IGetApp getApp, IAddNewApp addNewApp, IEditApp editApp, IDeleteApp deleteApp, ICheckUserPermissionToApp checkUserPermissionToApp, ICheckUserPermission checkUserPermission, ISessionService <LoggedUserModel> loggedUserSessionService) : base(managerSettings, loggerSettings, getUserApps, loggedUserSessionService) { this.deleteUser = deleteUser; this.getAppUsers = getAppUsers; this.getUserRole = getUserRole; this.revokeRole = revokeRole; this.grantRole = grantRole; this.deleteUserApp = deleteUserApp; this.addUserApp = addUserApp; this.getApp = getApp; this.getUserApps = getUserApps; this.addNewApp = addNewApp; this.editApp = editApp; this.deleteApp = deleteApp; this.checkUserPermissionToApp = checkUserPermissionToApp; this.checkUserPermission = checkUserPermission; this.getAllUsers = getAllUsers; Breadcrumb.Add("Application", "Index", "Application"); }
public IActionResult Edit(int id) { Breadcrumb.Add("Edit user", "Edit", "User"); if (!checkUserPermission.Invoke(LoggedUser.UserModel.Id, LoggedUser.AppId, id)) { Alert.Danger("You're not allowed to see this page"); return(View("Error")); } var model = (LoggedUser.UserModel.Id == id) ? LoggedUser.UserModel : getUserById.Invoke(id); var viewModelWrapper = new EditUserDetailsViewModel { Id = model.Id, Name = model.Name, Email = model.Email }; var userviewModel = new FormModel <EditUserDetailsViewModel>(viewModelWrapper, true); return(View(userviewModel)); }
public IActionResult Details(int id) { Breadcrumb.Add("User details", "Details", "User"); if (id == LoggedUser.UserModel.Id) { return(RedirectToAction("Me")); } if (!checkUserPermission.Invoke(LoggedUser.UserModel.Id, LoggedUser.AppId, id)) { Alert.Danger("You're not allowed to see this page"); return(View("Error")); } var model = getUserById.Invoke(id); var viewModel = new EditUserDetailsViewModel { Name = model.Name, Email = model.Email }; return(View(new FormModel <EditUserDetailsViewModel>(viewModel))); }
protected void Page_Load(object sender, EventArgs e) { if (SetupInfo.WorkMode == WorkMode.Promo) { Response.Redirect(FeedUrls.MainPageUrl, true); } if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add)) { Response.Redirect(FeedUrls.MainPageUrl, true); } Breadcrumb.Add(new BreadCrumb() { Caption = NewsResource.NewsBreadCrumbs, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") }); if (Info.HasUser) { Breadcrumb.Add(new BreadCrumb() { Caption = Info.User.DisplayUserName(false), NavigationUrl = string.Format(CultureInfo.CurrentCulture, "{0}?uid={1}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), Info.UserId) }); } var storage = FeedStorageFactory.Create(); Feed feed = null; long docID = 0; if (!string.IsNullOrEmpty(Request["docID"]) && long.TryParse(Request["docID"], out docID)) { feed = storage.GetFeed(docID); } if (!IsPostBack) { _errorMessage.Text = ""; if (feed != null) { if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit)) { Response.Redirect(FeedUrls.MainPageUrl, true); } FeedId = docID; FeedPoll pollFeed = feed as FeedPoll; if (pollFeed != null) { _pollMaster.QuestionFieldID = "feedName"; var question = pollFeed; _pollMaster.Singleton = (question.PollType == FeedPollType.SimpleAnswer); _pollMaster.Name = feed.Caption; _pollMaster.ID = question.Id.ToString(CultureInfo.CurrentCulture); foreach (var variant in question.Variants) { _pollMaster.AnswerVariants.Add(new ASC.Web.Controls.PollFormMaster.AnswerViarint() { ID = variant.ID.ToString(CultureInfo.CurrentCulture), Name = variant.Name }); } } } else { _pollMaster.QuestionFieldID = "feedName"; } } else { SaveFeed(); } if (feed != null) { Breadcrumb.Add(new BreadCrumb() { Caption = feed.Caption, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?docid=" + docID + Info.UserIdAttribute }); Breadcrumb.Add(new BreadCrumb() { Caption = NewsResource.NewsEditBreadCrumbsPoll, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editpoll.aspx") + "?docid=" + docID + Info.UserIdAttribute }); lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?docid=" + docID + Info.UserIdAttribute; } else { Breadcrumb.Add(new BreadCrumb() { Caption = NewsResource.NewsAddBreadCrumbsPoll, NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/editpoll.aspx") + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)) }); lbCancel.NavigateUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)); } this.Title = HeaderStringHelper.GetPageTitle(Resources.NewsResource.AddonName, Breadcrumb); }
public IActionResult ChangePassword() { Breadcrumb.Add("Change your password", "ChangePassword", "User"); return(View()); }
protected void Page_Load(object sender, EventArgs e) { if (SetupInfo.WorkMode == WorkMode.Promo) { Response.Redirect(FeedUrls.MainPageUrl, true); } Utility.RegisterTypeForAjax(this.GetType()); if (!CommunitySecurity.CheckPermissions(NewsConst.Action_Add)) { Response.Redirect(FeedUrls.MainPageUrl, true); } _mobileVer = Core.Mobile.MobileDetector.IsRequestMatchesMobile(this.Context); Breadcrumb.Add(new BreadCrumb { NavigationUrl = FeedUrls.MainPageUrl, Caption = NewsResource.NewsBreadCrumbs }); if (Info.HasUser) { Breadcrumb.Add(new BreadCrumb { Caption = Info.User.DisplayUserName(false), NavigationUrl = FeedUrls.GetFeedListUrl(Info.UserId) }); } var storage = FeedStorageFactory.Create(); Feed feed = null; if (!string.IsNullOrEmpty(Request["docID"])) { long docID; if (long.TryParse(Request["docID"], out docID)) { feed = storage.GetFeed(docID); Breadcrumb.Add(new BreadCrumb { Caption = feed.Caption ?? string.Empty, NavigationUrl = FeedUrls.GetFeedUrl(docID, Info.UserId) }); Breadcrumb.Add(new BreadCrumb { Caption = NewsResource.NewsEditBreadCrumbsNews, NavigationUrl = FeedUrls.EditNewsUrl + "?docID=" + docID + Info.UserIdAttribute }); _text = (feed != null ? feed.Text : "").HtmlEncode(); } } else { Breadcrumb.Add(new BreadCrumb { Caption = NewsResource.NewsAddBreadCrumbsNews, NavigationUrl = FeedUrls.EditNewsUrl + (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1)) }); } if (_mobileVer && IsPostBack) { _text = Request["mobiletext"] ?? ""; } if (!IsPostBack) { //feedNameRequiredFieldValidator.ErrorMessage = NewsResource.RequaredFieldValidatorCaption; HTML_FCKEditor.BasePath = VirtualPathUtility.ToAbsolute(CommonControlsConfigurer.FCKEditorBasePath); HTML_FCKEditor.ToolbarSet = "NewsToolbar"; HTML_FCKEditor.EditorAreaCSS = WebSkin.GetUserSkin().BaseCSSFileAbsoluteWebPath; HTML_FCKEditor.Visible = !_mobileVer; BindNewsTypes(); if (feed != null) { if (!CommunitySecurity.CheckPermissions(feed, NewsConst.Action_Edit)) { Response.Redirect(FeedUrls.MainPageName, true); } feedName.Text = feed.Caption; HTML_FCKEditor.Value = feed.Text; FeedId = feed.Id; feedType.SelectedIndex = (int)Math.Log((int)feed.FeedType, 2); } } else { var control = FindControl(Request.Params["__EVENTTARGET"]); if (lbCancel.Equals(control)) { CancelFeed(sender, e); } else { SaveFeed(); } } this.Title = HeaderStringHelper.GetPageTitle(NewsResource.AddonName, Breadcrumb); lbCancel.Attributes["name"] = HTML_FCKEditor.ClientID; }
protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(Default), Page); commentList.Visible = CommunitySecurity.CheckPermissions(NewsConst.Action_Comment); pgNavigator.EntryCount = 1; pgNavigator.EntryCountOnPage = 1; Breadcrumb.Add(new BreadCrumb { Caption = NewsResource.NewsBreadCrumbs, NavigationUrl = FeedUrls.MainPageUrl }); if (Info.HasUser) { Breadcrumb.Add(new BreadCrumb { Caption = Info.User.DisplayUserName(false), NavigationUrl = FeedUrls.GetFeedListUrl(Info.UserId) }); } if (!IsPostBack) { var storage = FeedStorageFactory.Create(); if (!string.IsNullOrEmpty(Request["docID"])) { long docID; if (long.TryParse(Request["docID"], out docID)) { //Show panel ContentView.Visible = false; FeedView.Visible = true; var feed = storage.GetFeed(docID); if (feed != null) { if (!feed.Readed) { storage.ReadFeed(feed.Id, SecurityContext.CurrentAccount.ID.ToString()); } FeedViewCtrl.Feed = feed; hdnField.Value = feed.Id.ToString(CultureInfo.CurrentCulture); Title += string.Format(CultureInfo.CurrentCulture, "-{0}", feed.Caption); InitCommentsView(storage, feed); FeedView.DataBind(); Breadcrumb.Add(new BreadCrumb { Caption = feed.Caption, NavigationUrl = FeedUrls.GetFeedUrl(docID, Info.UserId) }); } else { ContentView.Visible = true; FeedView.Visible = false; FeedRepeater.Visible = true; } } } else { PageNumber = string.IsNullOrEmpty(Request["page"]) ? 1 : Convert.ToInt32(Request["page"]); LoadData(); } } this.Title = HeaderStringHelper.GetPageTitle(Resources.NewsResource.AddonName, Breadcrumb); }
private void LoadData() { var storage = FeedStorageFactory.Create(); var feedType = FeedType.All; if (!string.IsNullOrEmpty(Request["type"])) { feedType = (FeedType)Enum.Parse(typeof(FeedType), Request["type"], true); var feedTypeInfo = FeedTypeInfo.FromFeedType(feedType); Breadcrumb.Add(new BreadCrumb { Caption = feedTypeInfo.TypeName, NavigationUrl = FeedUrls.GetFeedListUrl(feedType) }); if (!string.IsNullOrEmpty(Request["search"])) { Breadcrumb.Add(new BreadCrumb { Caption = HeaderStringHelper.GetHTMLSearchHeader(Request["search"]), NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?type=" + Request["type"] + "&search=" + Request["search"] + Info.UserIdAttribute }); } } else if (!string.IsNullOrEmpty(Request["search"])) { Breadcrumb.Add(new BreadCrumb { Caption = HeaderStringHelper.GetHTMLSearchHeader(Request["search"]), NavigationUrl = VirtualPathUtility.ToAbsolute("~/products/community/modules/news/") + "?search=" + Request["search"] + Info.UserIdAttribute }); } var feedsCount = !string.IsNullOrEmpty(Request["search"]) ? storage.SearchFeedsCount(Request["search"], feedType, Info.UserId) : storage.GetFeedsCount(feedType, Info.UserId); if (feedsCount == 0) { FeedRepeater.Visible = false; MessageShow.Visible = true; string buttonLink; string buttonName; var emptyScreenControl = new EmptyScreenControl { Describe = NewsResource.EmptyScreenText }; switch (feedType) { case FeedType.News: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_news.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenNewsCaption; buttonLink = FeedUrls.EditNewsUrl; buttonName = NewsResource.EmptyScreenNewsLink; break; case FeedType.Order: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_order.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenOrdersCaption; buttonLink = FeedUrls.EditOrderUrl; buttonName = NewsResource.EmptyScreenOrderLink; break; case FeedType.Advert: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_advert.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenAdvertsCaption; buttonLink = FeedUrls.EditAdvertUrl; buttonName = NewsResource.EmptyScreenAdvertLink; break; case FeedType.Poll: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_poll.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenPollsCaption; buttonLink = FeedUrls.EditPollUrl; buttonName = NewsResource.EmptyScreenPollLink; break; default: emptyScreenControl.ImgSrc = WebImageSupplier.GetAbsoluteWebPath("150x_newslogo.png", NewsConst.ModuleId); emptyScreenControl.Header = NewsResource.EmptyScreenEventsCaption; buttonLink = FeedUrls.EditNewsUrl; buttonName = NewsResource.EmptyScreenEventLink; break; } if (CommunitySecurity.CheckPermissions(NewsConst.Action_Add) && String.IsNullOrEmpty(Request["uid"]) && String.IsNullOrEmpty(Request["search"])) { emptyScreenControl.ButtonHTML = String.Format("<a class='linkAddMediumText' href='{0}'>{1}</a>", buttonLink, buttonName); } MessageShow.Controls.Add(emptyScreenControl); } else { const int pageSize = 20; var pageCount = (int)(feedsCount / pageSize + 1); if (pageCount < PageNumber) { PageNumber = pageCount; } var feeds = !string.IsNullOrEmpty(Request["search"]) ? storage.SearchFeeds(Request["search"], feedType, Info.UserId, pageSize, (PageNumber - 1) * pageSize) : storage.GetFeeds(feedType, Info.UserId, pageSize, (PageNumber - 1) * pageSize); pgNavigator.EntryCountOnPage = pageSize; pgNavigator.EntryCount = 0 < pageCount ? (int)feedsCount : pageSize; pgNavigator.CurrentPageNumber = PageNumber; pgNavigator.ParamName = "page"; if (!string.IsNullOrEmpty(Request["search"])) { pgNavigator.PageUrl = string.Format(CultureInfo.CurrentCulture, "{0}?search={1}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), Request["search"]); } else { pgNavigator.PageUrl = string.IsNullOrEmpty(Request["type"]) ? string.Format(CultureInfo.CurrentCulture, "{0}?{1}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), (string.IsNullOrEmpty(Info.UserIdAttribute) ? string.Empty : "?" + Info.UserIdAttribute.Substring(1))) : string.Format(CultureInfo.CurrentCulture, "{0}?type={1}{2}", VirtualPathUtility.ToAbsolute("~/products/community/modules/news/"), Request["type"], Info.UserIdAttribute); } FeedRepeater.DataSource = feeds; FeedRepeater.DataBind(); } }