diff --git a/NpgsqlBlogProvider/ChangeLog b/NpgsqlBlogProvider/ChangeLog index ceb4b524..fe331901 100644 --- a/NpgsqlBlogProvider/ChangeLog +++ b/NpgsqlBlogProvider/ChangeLog @@ -1,3 +1,8 @@ +2015-10-07 Paul Schneider + + * NpgsqlBlogProvider.cs: Fixes usage of Npgsql upgrade to + latest version + 2015-10-04 Paul Schneider * packages.config: diff --git a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs index 9f237b10..a5825052 100644 --- a/NpgsqlBlogProvider/NpgsqlBlogProvider.cs +++ b/NpgsqlBlogProvider/NpgsqlBlogProvider.cs @@ -407,7 +407,7 @@ namespace Npgsql.Web.Blog if (circles.Length>0) using (NpgsqlCommand cmd = cnx.CreateCommand ()) { cmd.CommandText = "insert into blog_access (post_id,circle_id) values (:pid,:cid)"; - cmd.Parameters.AddWithValue ("pid", pid); + cmd.Parameters.AddWithValue ("pid", NpgsqlTypes.NpgsqlDbType.Bigint, pid); cmd.Parameters.Add ("cid", NpgsqlTypes.NpgsqlDbType.Bigint); cmd.Prepare (); foreach (long ci in circles) { diff --git a/TestAPI/BlogUnitTest.cs b/TestAPI/BlogUnitTest.cs new file mode 100644 index 00000000..be591a08 --- /dev/null +++ b/TestAPI/BlogUnitTest.cs @@ -0,0 +1,76 @@ +// +// BlogUnitTest.cs +// +// Author: +// Paul Schneider +// +// Copyright (c) 2015 GNU GPL +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +using NUnit.Framework; +using System; +using Yavsc.Model.Blogs; +using Yavsc.Controllers; +using System.Web.Mvc; +using System.Web.Security; + +namespace TestAPI +{ + [TestFixture ()] + public class BlogUnitTest + { + + public string UserName { get; set; } + public string Email { get; set; } + public string Password { get; set; } + + + AccountController accountController; + [TestFixtureSetUp] + public void Init() + { + accountController = new AccountController (); + } + + [Test ()] + public void Register () + { + ViewResult actionResult = accountController.Register ( + new Yavsc.Model.RolesAndMembers.RegisterViewModel () { + UserName = UserName, Email = Email, + Password = "tpwd", ConfirmPassword = Password, + IsApprouved = true + }, + "/testreturnurl") as ViewResult; + Assert.AreEqual (actionResult.ViewName, "RegistrationPending"); + MembershipUser u = Membership.GetUser (UserName, false); + Assert.NotNull (u); + Assert.False (u.IsApproved); + // TODO : check mail for test, + // get the validation key from its body, + // and use the accountController.Validate(username,key) + u.IsApproved = true; + Membership.UpdateUser (u); + Assert.True (u.IsApproved); + } + [TestFixtureTearDown()] + public void Unregister() + { + ViewResult actionResult = + accountController.Unregister (UserName, true) as ViewResult; + Assert.AreEqual (actionResult.ViewName, "Index"); + } + } +} + diff --git a/TestAPI/ChangeLog b/TestAPI/ChangeLog index 5210c59a..74fc3d9e 100644 --- a/TestAPI/ChangeLog +++ b/TestAPI/ChangeLog @@ -1,3 +1,9 @@ +2015-10-07 Paul Schneider + + * BlogUnitTest.cs: Should test the user registration + + * TestAPI.csproj: switch to .Net framework 4.5.1 + 2015-10-04 Paul Schneider * TestAPI.csproj: diff --git a/TestAPI/TestAPI.csproj b/TestAPI/TestAPI.csproj index ed962888..8e601b4c 100644 --- a/TestAPI/TestAPI.csproj +++ b/TestAPI/TestAPI.csproj @@ -9,7 +9,7 @@ Library TestAPI TestAPI - v4.5 + v4.5.1 true @@ -55,10 +55,14 @@ ..\packages\Spark.1.8.1.0\lib\NET45\Spark.dll + + + + @@ -66,6 +70,10 @@ {68F5B80A-616E-4C3C-91A0-828AA40000BD} YavscModel + + {77044C92-D2F1-45BD-80DD-AA25B311B027} + Web + diff --git a/web/ApiControllers/AccountController.cs b/web/ApiControllers/AccountController.cs index 6c45c52c..1a7e2362 100644 --- a/web/ApiControllers/AccountController.cs +++ b/web/ApiControllers/AccountController.cs @@ -72,7 +72,7 @@ namespace Yavsc.ApiControllers break; case MembershipCreateStatus.Success: if (!model.IsApprouved) - YavscHelpers.SendActivationMessage (user); + Url.SendActivationMessage (user); ProfileBase prtu = ProfileBase.Create (model.UserName); prtu.SetPropertyValue("Name",model.Name); prtu.SetPropertyValue("Address",model.Address); @@ -99,9 +99,12 @@ namespace Yavsc.ApiControllers public void ResetPassword(LostPasswordModel model) { StringDictionary errors; - YavscHelpers.ResetPassword (model, out errors); + MembershipUser user; + YavscHelpers.ValidatePasswordReset (model, out errors, out user); foreach (string key in errors.Keys) ModelState.AddModelError (key, errors [key]); + if (user != null && ModelState.IsValid) + Url.SendActivationMessage (user); } } } diff --git a/web/ApiControllers/CalendarController.cs b/web/ApiControllers/CalendarController.cs index 9919ff1b..d1b8300f 100644 --- a/web/ApiControllers/CalendarController.cs +++ b/web/ApiControllers/CalendarController.cs @@ -27,6 +27,7 @@ using Yavsc.Helpers; using System.Web.Profile; using Yavsc.Model.Circles; using Yavsc.Model.Calendar; +using System.Web.Http.Routing; namespace Yavsc.ApiControllers @@ -160,7 +161,7 @@ namespace Yavsc.ApiControllers "déjà enregistré"); break; case MembershipCreateStatus.Success: - YavscHelpers.SendActivationMessage (user); + Url.SendActivationMessage (user); // TODO set registration id throw new NotImplementedException (); } diff --git a/web/ApiControllers/WorkFlowController.cs b/web/ApiControllers/WorkFlowController.cs index 8a79f680..ca0cf435 100644 --- a/web/ApiControllers/WorkFlowController.cs +++ b/web/ApiControllers/WorkFlowController.cs @@ -85,7 +85,8 @@ namespace Yavsc.ApiControllers return ; case MembershipCreateStatus.Success: if (!userModel.IsApprouved) - YavscHelpers.SendActivationMessage (user); + + Url.SendActivationMessage (user); return; default: throw new InvalidOperationException (string.Format("Unexpected user creation code :{0}",mcs)); diff --git a/web/App_Themes/style.css b/web/App_Themes/style.css index 71e630e6..5d484951 100644 --- a/web/App_Themes/style.css +++ b/web/App_Themes/style.css @@ -235,7 +235,6 @@ input, select { .menuitem { - background-color: rgba(0,0,40,.8); border-radius:5px; margin:.5em; padding:.5em; diff --git a/web/ChangeLog b/web/ChangeLog index d555dba4..d3d7badb 100644 --- a/web/ChangeLog +++ b/web/ChangeLog @@ -1,3 +1,28 @@ +2015-10-07 Paul Schneider + + * AccountController.cs: refactoring password validation + + * CalendarController.cs: + * WorkFlowController.cs: SendActivationMessage became an + extension method + + * style.css: menu items already have a background and color, + since they're `` tags + + * Unregister.aspx: + * AccountController.cs: refactoring user registration + + * BlogsController.cs: Fixes a confusion between Author and + reader ... + + * YavscHelpers.cs: refactoring the password reset + + * App.master: no more <% } else { %> - - " accesskey="L" class="menuitem"> <%= HttpContext.Current.User.Identity.Name %> diff --git a/web/Views/Account/Login.aspx b/web/Views/Account/Login.aspx index 00306c42..ba09a7da 100644 --- a/web/Views/Account/Login.aspx +++ b/web/Views/Account/Login.aspx @@ -20,7 +20,7 @@ <% } %>
-<%= Html.ActionLink("S'enregistrer","Register",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %> +<%= Html.ActionLink("S'enregistrer","RegisterForm",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %>
?returnUrl=<%=ViewData["returnUrl"]==null?Request.Url.PathAndQuery:(string)ViewData["returnUrl"]%>" class="actionlink"> diff --git a/web/Views/Account/Profile.aspx b/web/Views/Account/Profile.aspx index f04f9791..9c016311 100644 --- a/web/Views/Account/Profile.aspx +++ b/web/Views/Account/Profile.aspx @@ -112,7 +112,7 @@ Avatar : - <%= Html.ActionLink("Désincription","Unregister", "Account",null, new { @class="actionlink" })%> + <%= Html.ActionLink("Désincription","Unregister", "Account", new { id=ViewData["UserName"] } , new { @class="actionlink" })%>