1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Creating simple interface for moderators

Creating simple interface for moderators

10 posts, 0 answered
  1. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    10 Mar 2009
    Link to this post

    Hello!!!

    I have one important question:

    I want to make interface such as in Sitefinity dashboard. In this interface I want to provide access to moderators of news, polls and e.t.c I want create simple interface and login form for moderators. How can I do? Do you have example?

  2. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    10 Mar 2009
    Link to this post

    I'm trying to create a new role (in my test web application) in this code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Cms;

    namespace WebExtDemo1
    {
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    Telerik.Security.UserManager userman = new Telerik.Security.UserManager("Default");
    userman.CreateRole("Publishers");
    }
    }
    }

    I added to this project Telerik.Cms, Telerik.Cms.Data, Telerik.Cms.Engine, Telerik.Cms.Web.UI, Telerik.Framework, Telerik.Personalization, Telerik.Personalization.Data

    but I take the error Role feature is not enabled.

    What I must do?

  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Mar 2009
    Link to this post
    Hello rent,

    The code seems to be correct. Check out whether you have the following line in your web.config - enabled attribute should be set to true as the example below demonstrates. Just to let you know, default provider is Sitefinity.

    <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="Sitefinity"

    As for the interface you are asking in the other post, you could create a landing page for your users where they should authenticate and then they will be redirected to desired destination.

    if (man.IsUserInRole("Moderators")) 
            { 
                // redirect users 
                Response.Redirect(string URL); 
            } 

    I hope this helps.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    10 Mar 2009
    Link to this post

    I made modifications in Web.config file:

      <connectionStrings>
    <add name="Sitefinity" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Sitefinity.mdf"
    providerName="System.Data.SqlClient" />
    </connectionStrings>

     ....... and.....

      <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="Sitefinity">
    <providers>
    <clear />
    <add connectionStringName="Sitefinity" applicationName="/"
    name="Sitefinity" type="Telerik.DataAccess.AspnetProviders.TelerikRoleProvider, Telerik.DataAccess" />
    </providers>
    </roleManager>

    but in the running I give the configuration error on line 

    name="Sitefinity" type="Telerik.DataAccess.AspnetProviders.TelerikRoleProvider, Telerik.DataAccess" />
    with text In an object copy the reference to the object is not set.

  5. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    10 Mar 2009
    Link to this post
    My previos questions is not correct. But I have one question:
    For solving my problem I created folder Publishers that contains two pages:
    PublishersLogin.aspx and Publishers.aspx.
    PublishersLogin.aspx - for authenticate users in publishers role.
    Publishers.aspx - page which contains the simple interface for modifying and creating news, polls, events by the users in publishers role.
    Question:
    I want that the users can view page Publishers.aspx always only after the authenticating on the page PublishersLogin.aspx . That is if the user would to view page Publishers.aspx that redirect to PublishersLogin.aspx.
    How I can do it?
    Thanks for answers!
  6. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    10 Mar 2009
    Link to this post

    I forgot my PublishersLogin.aspx page code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.Security;
    using System.Web.UI.WebControls;
    using Telerik.Security;

    public partial class Publishers_PublishersLogin : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
    e.Authenticated = UserManager.Default.ValidateUser(Login1.UserName, Login1.Password);
    }
    protected void Login1_LoggedIn(object sender, EventArgs e)
    {
    HttpCookie cookie = this.Response.Cookies[FormsAuthentication.FormsCookieName];
    UserManager.Default.SetAuthenticationCookie(cookie);
    this.Page.Response.Redirect("Publishers.aspx");

    }
    }



  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Mar 2009
    Link to this post
    Hello rent,

    You could try the following logic.

    Under your Publishers.aspx Page_Load put the following logic.

       if (!Page.User.Identity.IsAuthenticated) 
            { 
                Response.Redirect("PublishLogin.aspx"); 
            } 

    The on PublishLogin put Login control

    <asp:Login ID="Login1" runat="server"></asp:Login> 


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    10 Mar 2009
    Link to this post
    How to write the JavaScript code which will be delete the authenticate cookies when the window n brother close?
  9. rent
    rent avatar
    104 posts
    Registered:
    05 May 2008
    11 Mar 2009
    Link to this post

    I want to delete cookies when page closed. I write this code:

    HttpCookieCollection cookies = this.Page.Response.Cookies;
    for (int i = 0; i < cookies.Count; i++)
    {
    HttpCookie cookie = cookies[i];
    cookies.Remove(cookie.Name);
    }
    But I don't know  where insert this code.... Help me please

  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Mar 2009
    Link to this post
    Hi rent,

    Generally you can put the code in the master page. I am not sure whether you will be able to delete the cookie using this way. Please check this article at MSDN.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
10 posts, 0 answered