diff --git a/NpgsqlMRPProviders/ChangeLog b/NpgsqlMRPProviders/ChangeLog index 239e4e184..b9136c471 100644 --- a/NpgsqlMRPProviders/ChangeLog +++ b/NpgsqlMRPProviders/ChangeLog @@ -1,3 +1,8 @@ +2015-11-04 Paul Schneider + + * NpgsqlProfileProvider.cs: + * NpgsqlMembershipProvider.cs: + 2015-11-03 Paul Schneider * NpgsqlMembershipProvider.cs: Fixes the latest commit diff --git a/NpgsqlMRPProviders/NpgsqlMembershipProvider.cs b/NpgsqlMRPProviders/NpgsqlMembershipProvider.cs index 454c02111..049883def 100644 --- a/NpgsqlMRPProviders/NpgsqlMembershipProvider.cs +++ b/NpgsqlMRPProviders/NpgsqlMembershipProvider.cs @@ -378,15 +378,20 @@ namespace Npgsql.Web conn.Open (); NpgsqlTransaction tran = conn.BeginTransaction(); + long prid = 0; 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.Parameters.AddWithValue ("uname", username); 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 " + " (PKID, Username, Passw, Email, PasswordQuestion, " + " PasswordAnswer, IsApproved," + diff --git a/NpgsqlMRPProviders/NpgsqlProfileProvider.cs b/NpgsqlMRPProviders/NpgsqlProfileProvider.cs index f8cf83c5c..b0e454568 100644 --- a/NpgsqlMRPProviders/NpgsqlProfileProvider.cs +++ b/NpgsqlMRPProviders/NpgsqlProfileProvider.cs @@ -275,11 +275,12 @@ namespace Npgsql.Web long c = (long)cmdpi.ExecuteScalar (); 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) " + "values ( @username, @appname ) " + "returning uniqueid"; - puid = (long)cmdpi.ExecuteScalar (); + puid = (long) cmdpi.ExecuteScalar (); using (NpgsqlCommand cmdpdins = cnx.CreateCommand ()) { cmdpdins.CommandText = "insert into profiledata (uniqueid) values (@puid)"; @@ -287,13 +288,13 @@ namespace Npgsql.Web cmdpdins.ExecuteNonQuery (); } } else { + // here we're roughly sure to get the id cmdpi.CommandText = "select uniqueid from profiles where username = @username " + "and applicationname = @appname"; puid = (long)cmdpi.ExecuteScalar (); } } - foreach (SettingsPropertyValue s in collection) { if (s.UsingDefaultValue) { //TODO Drop the property in the profile diff --git a/web/ChangeLog b/web/ChangeLog index 033d79402..d6285fc3e 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,14 @@ +2015-11-04 Paul Schneider + + * Web.csproj: + * AppAdmin.master: + * AddRole.aspx: + * OAuth2.cs: + * RoleList.aspx: + * UsersInRole.aspx: + * AdminController.cs: + * AddMemberToRole.ascx: + 2015-11-04 Paul Schneider * instdbws.sql: diff --git a/web/Controllers/AdminController.cs b/web/Controllers/AdminController.cs index 90e64d750..57ed5c5b8 100644 --- a/web/Controllers/AdminController.cs +++ b/web/Controllers/AdminController.cs @@ -24,12 +24,11 @@ namespace Yavsc.Controllers /// public ActionResult Index() { + // FIXME do this in a new installation script. if (!Roles.RoleExists (roleName)) { Roles.CreateRole (roleName); YavscHelpers.Notify (ViewData, roleName + " " + LocalizedText.role_created); - } - return View (); } /// diff --git a/web/Helpers/Google/OAuth2.cs b/web/Helpers/Google/OAuth2.cs index 129b74f7c..03da8e167 100644 --- a/web/Helpers/Google/OAuth2.cs +++ b/web/Helpers/Google/OAuth2.cs @@ -76,7 +76,7 @@ namespace Yavsc.Helpers.Google { 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); GetAuthResponse (bresp, prms); } diff --git a/web/Models/AppAdmin.master b/web/Models/AppAdmin.master index e5d623432..ce7c3e061 100644 --- a/web/Models/AppAdmin.master +++ b/web/Models/AppAdmin.master @@ -58,6 +58,7 @@ else {%> Yavsc.notice(<%=note.body%>, <%=note.click_action%>); <% } %>
  • <%= Html.ActionLink("Restaurations", "Restore") %>
  • <%= Html.ActionLink("Create backup","CreateBackup") %>
  • <%= Html.ActionLink("Remove user", "RemoveUser") %>
  • +
  • <%= Html.ActionLink("Add a Role ", "AddRole") %>
  • <%= Html.ActionLink("Remove role", "RemoveRoleQuery") %>
  • <%= Html.ActionLink("User list", "UserList") %>
  • <%= Html.ActionLink("Role list", "RoleList") %>
  • diff --git a/web/Views/Admin/AddMemberToRole.ascx b/web/Views/Admin/AddMemberToRole.ascx new file mode 100644 index 000000000..bc63fa55d --- /dev/null +++ b/web/Views/Admin/AddMemberToRole.ascx @@ -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", "*") %>
    + +<% } %> + diff --git a/web/Views/Admin/AddRole.aspx b/web/Views/Admin/AddRole.aspx index 3f9f40dac..ded100555 100644 --- a/web/Views/Admin/AddRole.aspx +++ b/web/Views/Admin/AddRole.aspx @@ -9,6 +9,7 @@ Nom du rôle : <%= Html.ValidationMessage("RoleName", "*") %>
    <% } %> +<%= Html.Partial("AddMemberToRole")%> diff --git a/web/Views/Admin/RoleList.aspx b/web/Views/Admin/RoleList.aspx index 2f063f316..613ffead0 100644 --- a/web/Views/Admin/RoleList.aspx +++ b/web/Views/Admin/RoleList.aspx @@ -4,7 +4,7 @@ Roles:
      <%foreach (string rolename in (string[]) Model){ %> -
    • <%=rolename%> <% if (Roles.IsUserInRole("Admin")) { %> +
    • <%=Html.ActionLink(rolename,"UsersInRole", new { rolename = rolename }, new { @class="actionlink" } )%> <% if (Roles.IsUserInRole("Admin")) { %> <%= Html.ActionLink("Supprimer","RemoveRole", new { rolename = rolename }, new { @class="actionlink" } ) %> <% } %>
    • <% } %> diff --git a/web/Views/Admin/UsersInRole.aspx b/web/Views/Admin/UsersInRole.aspx new file mode 100644 index 000000000..a294ef8c8 --- /dev/null +++ b/web/Views/Admin/UsersInRole.aspx @@ -0,0 +1,11 @@ +<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %> + + + + + + +
      + +
      + diff --git a/web/Web.csproj b/web/Web.csproj index e9a05e6ef..dae55fdc6 100644 --- a/web/Web.csproj +++ b/web/Web.csproj @@ -252,7 +252,6 @@ - @@ -469,6 +468,9 @@ + + +