如何根据登录用户按组ID显示模板,如何根据用户组限制对控制器的访问。
我的控制器:
public function index()
{
if (!$this->ion_auth->in_group('admin'))
{
$this->template->administrator('dashboard/dashboard');
}
elseif (!$this->ion_auth->in_group('2'))
{
$this->template->admin('dashboard/dashboard');
}
elseif (!$this->ion_auth->in_group('3'))
{
$this->template->user('dashboard/dashboard');
}
elseif (!$this->ion_auth->in_group('members'))
{
$this->template->client('dashboard/dashboard');
}
else
{
redirect('account/sign_in', 'refresh');
}
}
答案 0 :(得分:0)
尝试并询问后,最终我得到了正确的结果,我可以使用,如下面的代码:
<asp:ScriptManager ID="smDDL" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="upDDL" runat="server">
<ContentTemplate>
<div class="form-group" style="margin-bottom: 25px;">
<asp:Label ID="lblCType" runat="server" Text="Complaint Type" data-toggle="tooltip" title="Select Complaint Type" />
<asp:RequiredFieldValidator ID="RfvDDLCompType" runat="server" ErrorMessage="Please Select Complaint Type" ControlToValidate="ddlCType" ForeColor="Red" InitialValue="0" Display="Dynamic"> *</asp:RequiredFieldValidator>
<asp:DropDownList ID="ddlCType" runat="server" CssClass="form-control" DataSourceID="SqlDataSource1" DataTextField="Comp_Type" DataValueField="Type_ID" AutoPostBack="True" OnDataBound="DDLCTypeDataBound" Style="width: 400px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ComplaintWebsiteConnectionString %>" SelectCommand="SELECT * FROM [Complaint_Type]"></asp:SqlDataSource>
</div>
<div class="form-group" style="margin-bottom: 25px;">
<asp:Label ID="lblSubType" runat="server" Text="Complaint Sub Type" data-toggle="tooltip" title="Select Complaint Sub Type" />
<asp:RequiredFieldValidator ID="rfvDDlSubType" runat="server" ErrorMessage="Please Select Complaint Sub Type" ControlToValidate="ddlSubType" ForeColor="Red" InitialValue="0" Display="Dynamic"> *</asp:RequiredFieldValidator>
<asp:DropDownList ID="ddlSubType" runat="server" CssClass="form-control" DataSourceID="SqlDataSource2" DataTextField="Comp_SubType" DataValueField="Type_ID" OnDataBound="DDLSubTypeDataBound" Style="width: inherit">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ComplaintWebsiteConnectionString %>" SelectCommand="SELECT * FROM [Complaint_SubType] WHERE ([Type_ID] = @Type_ID2)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCType" Name="Type_ID2" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</ContentTemplate>
</asp:UpdatePanel>
希望这个答案有用并享受编码的时间......:)