Adds UI to enrole members

main
Paul Schneider 10 years ago
parent bc6feacbee
commit 0b8b717f3e
12 changed files with 58 additions and 11 deletions

@ -1,3 +1,8 @@
2015-11-04 Paul Schneider <paul@pschneider.fr>
* NpgsqlProfileProvider.cs:
* NpgsqlMembershipProvider.cs:
2015-11-03 Paul Schneider <paul@pschneider.fr> 2015-11-03 Paul Schneider <paul@pschneider.fr>
* NpgsqlMembershipProvider.cs: Fixes the latest commit * NpgsqlMembershipProvider.cs: Fixes the latest commit

@ -378,15 +378,20 @@ namespace Npgsql.Web
conn.Open (); conn.Open ();
NpgsqlTransaction tran = conn.BeginTransaction(); NpgsqlTransaction tran = conn.BeginTransaction();
long prid = 0;
using (NpgsqlCommand cmd = new NpgsqlCommand ("INSERT INTO profiles (username,applicationname,isanonymous)\n" + using (NpgsqlCommand cmd = new NpgsqlCommand ("INSERT INTO profiles (username,applicationname,isanonymous)\n" +
"VALUES (:uname,:app,FALSE)")) { "VALUES (:uname,:app,FALSE) returning uniqueid")) {
cmd.Connection = conn; cmd.Connection = conn;
cmd.Parameters.AddWithValue ("uname", username); cmd.Parameters.AddWithValue ("uname", username);
cmd.Parameters.AddWithValue ("app", pApplicationName); cmd.Parameters.AddWithValue ("app", pApplicationName);
cmd.ExecuteNonQuery (); prid = (long) cmd.ExecuteScalar();
}
using (NpgsqlCommand cmdpdins = conn.CreateCommand ()) {
cmdpdins.CommandText = "insert into profiledata (uniqueid) values (@puid)";
cmdpdins.Parameters.AddWithValue ("@puid", prid);
cmdpdins.ExecuteNonQuery ();
} }
using (NpgsqlCommand cmd = new NpgsqlCommand ("INSERT INTO Users " + using (NpgsqlCommand cmd = new NpgsqlCommand ("INSERT INTO Users " +
" (PKID, Username, Passw, Email, PasswordQuestion, " + " (PKID, Username, Passw, Email, PasswordQuestion, " +
" PasswordAnswer, IsApproved," + " PasswordAnswer, IsApproved," +

@ -275,11 +275,12 @@ namespace Npgsql.Web
long c = (long)cmdpi.ExecuteScalar (); long c = (long)cmdpi.ExecuteScalar ();
if (c == 0) { if (c == 0) {
// the `isanonymous` field is specified true by default // This is a new anonymous profile.
// the `isanonymous` field should be specified true by default in the ddl
cmdpi.CommandText = "insert into profiles (username,applicationname) " + cmdpi.CommandText = "insert into profiles (username,applicationname) " +
"values ( @username, @appname ) " + "values ( @username, @appname ) " +
"returning uniqueid"; "returning uniqueid";
puid = (long)cmdpi.ExecuteScalar (); puid = (long) cmdpi.ExecuteScalar ();
using (NpgsqlCommand cmdpdins = cnx.CreateCommand ()) { using (NpgsqlCommand cmdpdins = cnx.CreateCommand ()) {
cmdpdins.CommandText = "insert into profiledata (uniqueid) values (@puid)"; cmdpdins.CommandText = "insert into profiledata (uniqueid) values (@puid)";
@ -287,13 +288,13 @@ namespace Npgsql.Web
cmdpdins.ExecuteNonQuery (); cmdpdins.ExecuteNonQuery ();
} }
} else { } else {
// here we're roughly sure to get the id
cmdpi.CommandText = "select uniqueid from profiles where username = @username " + cmdpi.CommandText = "select uniqueid from profiles where username = @username " +
"and applicationname = @appname"; "and applicationname = @appname";
puid = (long)cmdpi.ExecuteScalar (); puid = (long)cmdpi.ExecuteScalar ();
} }
} }
foreach (SettingsPropertyValue s in collection) { foreach (SettingsPropertyValue s in collection) {
if (s.UsingDefaultValue) { if (s.UsingDefaultValue) {
//TODO Drop the property in the profile //TODO Drop the property in the profile

@ -1,3 +1,14 @@
2015-11-04 Paul Schneider <paul@pschneider.fr>
* Web.csproj:
* AppAdmin.master:
* AddRole.aspx:
* OAuth2.cs:
* RoleList.aspx:
* UsersInRole.aspx:
* AdminController.cs:
* AddMemberToRole.ascx:
2015-11-04 Paul Schneider <paul@pschneider.fr> 2015-11-04 Paul Schneider <paul@pschneider.fr>
* instdbws.sql: * instdbws.sql:

@ -24,12 +24,11 @@ namespace Yavsc.Controllers
/// </summary> /// </summary>
public ActionResult Index() public ActionResult Index()
{ {
// FIXME do this in a new installation script.
if (!Roles.RoleExists (roleName)) { if (!Roles.RoleExists (roleName)) {
Roles.CreateRole (roleName); Roles.CreateRole (roleName);
YavscHelpers.Notify (ViewData, roleName + " " + LocalizedText.role_created); YavscHelpers.Notify (ViewData, roleName + " " + LocalizedText.role_created);
} }
return View (); return View ();
} }
/// <summary> /// <summary>

@ -76,7 +76,7 @@ namespace Yavsc.Helpers.Google
{ {
string scope = string.Join ("%20", scopeOpenid); string scope = string.Join ("%20", scopeOpenid);
string prms = String.Format ("response_type=code&client_id={0}&redirect_uri={1}&scope={2}&state={3}&include_granted_scopes=false", string prms = String.Format ("response_type=code&client_id={0}&redirect_uri={1}&scope={2}&state={3}&include_granted_scopes=false&approval_prompt=force",
CLIENT_ID, RedirectUri, scope, state); CLIENT_ID, RedirectUri, scope, state);
GetAuthResponse (bresp, prms); GetAuthResponse (bresp, prms);
} }

@ -58,6 +58,7 @@ else {%> Yavsc.notice(<%=note.body%>, <%=note.click_action%>); <% } %>
<li><%= Html.ActionLink("Restaurations", "Restore") %></li> <li><%= Html.ActionLink("Restaurations", "Restore") %></li>
<li><%= Html.ActionLink("Create backup","CreateBackup") %></li> <li><%= Html.ActionLink("Create backup","CreateBackup") %></li>
<li><%= Html.ActionLink("Remove user", "RemoveUser") %></li> <li><%= Html.ActionLink("Remove user", "RemoveUser") %></li>
<li><%= Html.ActionLink("Add a Role ", "AddRole") %></li>
<li><%= Html.ActionLink("Remove role", "RemoveRoleQuery") %></li> <li><%= Html.ActionLink("Remove role", "RemoveRoleQuery") %></li>
<li><%= Html.ActionLink("User list", "UserList") %></li> <li><%= Html.ActionLink("User list", "UserList") %></li>
<li><%= Html.ActionLink("Role list", "RoleList") %></li> <li><%= Html.ActionLink("Role list", "RoleList") %></li>

@ -0,0 +1,11 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%= Html.ValidationSummary() %>
<% using(Ajax.BeginForm())
{ %>
Nom du rôle :
<%= Html.TextBox( "RoleName" ) %>
<%= Html.ValidationMessage("RoleName", "*") %><br/>
<input class="actionlink" type="submit"/>
<% } %>

@ -9,6 +9,7 @@ Nom du rôle :
<%= Html.ValidationMessage("RoleName", "*") %><br/> <%= Html.ValidationMessage("RoleName", "*") %><br/>
<input class="actionlink" type="submit"/> <input class="actionlink" type="submit"/>
<% } %> <% } %>
<%= Html.Partial("AddMemberToRole")%>
</asp:Content> </asp:Content>

@ -4,7 +4,7 @@ Roles:
<ul> <ul>
<%foreach (string rolename in (string[]) Model){ %> <%foreach (string rolename in (string[]) Model){ %>
<li><%=rolename%> <% if (Roles.IsUserInRole("Admin")) { %> <li><%=Html.ActionLink(rolename,"UsersInRole", new { rolename = rolename }, new { @class="actionlink" } )%> <% if (Roles.IsUserInRole("Admin")) { %>
<%= Html.ActionLink("Supprimer","RemoveRole", new { rolename = rolename }, new { @class="actionlink" } ) %> <%= Html.ActionLink("Supprimer","RemoveRole", new { rolename = rolename }, new { @class="actionlink" } ) %>
<% } %></li> <% } %></li>
<% } %> <% } %>

@ -0,0 +1,11 @@
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</body>

@ -252,7 +252,6 @@
<Content Include="Views\Admin\Backups.aspx" /> <Content Include="Views\Admin\Backups.aspx" />
<Content Include="Views\Admin\Restore.aspx" /> <Content Include="Views\Admin\Restore.aspx" />
<Content Include="Views\Admin\Restored.aspx" /> <Content Include="Views\Admin\Restored.aspx" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Views\FrontOffice\Estimates.aspx" /> <Content Include="Views\FrontOffice\Estimates.aspx" />
<Content Include="Catalog.xml" /> <Content Include="Catalog.xml" />
<Content Include="RegistrationMail.txt" /> <Content Include="RegistrationMail.txt" />
@ -469,6 +468,9 @@
<Content Include="App_Themes\images\star-939235_1280.jpg" /> <Content Include="App_Themes\images\star-939235_1280.jpg" />
<Content Include="App_Themes\images\star-939235_1280.s.jpg" /> <Content Include="App_Themes\images\star-939235_1280.s.jpg" />
<Content Include="App_Themes\images\star-939235_1280.xxs.jpg" /> <Content Include="App_Themes\images\star-939235_1280.xxs.jpg" />
<Content Include="Views\Admin\AddMemberToRole.ascx" />
<Content Include="Views\Admin\UsersInRole.aspx" />
<Content Include="Views\Admin\Index.aspx" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

Loading…