* AccountController.cs: Register and reset passord
from Web API * GCMController.cs: initial creation, will host GCM calls and related procedures. * ResetPassword.aspx: Html view to reset the password * LocalizedText.resx: * LocalizedText.fr.resx: new String form circles * Web.config: * Web.csproj: * YavscModel.csproj: * LocalizedText.Designer.cs: * Profile.cs: * Profile.cs: * LocalizedText.fr.Designer.cs: * LoginModel.cs: * Publishing.cs: * CalendarController.cs: * LoginModel.cs: * GCMRegister.cs: * Publishing.cs: * GCMRegister.cs: * NewRoleModel.cs: * NewRoleModel.cs: * RegisterModel.cs: * NewAdminModel.cs: * RegisterModel.cs: * NewAdminModel.cs: * LostPasswordModel.cs: * RegisterViewModel.cs: * RegisterViewModel.cs: * ProviderPublicInfo.cs: * RegisterClientModel.cs: * ChangePasswordModel.cs: * ProviderPublicInfo.cs: * RegisterClientModel.cs: * ChangePasswordModel.cs: Fixes a typo (in the namespace :-/) * NpgsqlCircleProvider.cs: Fixes the Circle creation * Global.asax.cs: * AdminController.cs: * NpgsqlContentProvider.cs: code formatting * BlogsController.cs: * CircleController.cs: * WorkFlowController.cs: * PaypalApiController.cs: * FrontOfficeController.cs: refactoring * AccountController.cs: Adds the way to reset the password * FrontOfficeController.cs: xml doc * T.cs: Make this class an helper to translation * YavscHelpers.cs: Implements the e-mail sending * style.css: style uniformization * Circles.aspx: Implements the Html interface to Circle creation (modifications and deletions are still to implement) * Register.ascx: Allows the error display in case of lack of power of the user at registering another user. * Estimate.aspx: use the partial view to register from the Account folder. Cleans the useless reference to ~/Theme/dark/style.css, that was for using the "tablesorter.js", no used anymore. * Web.config: Trying to have all the Index pages to work...
This commit is contained in:
parent
597b674b74
commit
53930befd3
44 changed files with 705 additions and 135 deletions
111
web/ApiControllers/AccountController.cs
Normal file
111
web/ApiControllers/AccountController.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
//
|
||||
// AccountController.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using System.Web.Http;
|
||||
using System.Net.Http;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using System.Web.Security;
|
||||
using System.Web.Profile;
|
||||
using Yavsc.Helpers;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
public class AccountController : ApiController
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Register the specified model.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
[Authorize()]
|
||||
[ValidateAjaxAttribute]
|
||||
public HttpResponseMessage Register ([FromBody] RegisterClientModel model)
|
||||
{
|
||||
if (ModelState.IsValid) {
|
||||
if (model.IsApprouved)
|
||||
if (!Roles.IsUserInRole ("Admin"))
|
||||
if (!Roles.IsUserInRole ("FrontOffice")) {
|
||||
ModelState.AddModelError ("Register",
|
||||
"Since you're not member of Admin or FrontOffice groups, " +
|
||||
"you cannot ask for a pre-approuved registration");
|
||||
return DefaultResponse ();
|
||||
}
|
||||
MembershipCreateStatus mcs;
|
||||
var user = Membership.CreateUser (
|
||||
model.UserName,
|
||||
model.Password,
|
||||
model.Email,
|
||||
null,
|
||||
null,
|
||||
model.IsApprouved,
|
||||
out mcs);
|
||||
switch (mcs) {
|
||||
case MembershipCreateStatus.DuplicateEmail:
|
||||
ModelState.AddModelError ("Email", "Cette adresse e-mail correspond " +
|
||||
"à un compte utilisateur existant");
|
||||
break;
|
||||
case MembershipCreateStatus.DuplicateUserName:
|
||||
ModelState.AddModelError ("UserName", "Ce nom d'utilisateur est " +
|
||||
"déjà enregistré");
|
||||
break;
|
||||
case MembershipCreateStatus.Success:
|
||||
if (!model.IsApprouved)
|
||||
YavscHelpers.SendActivationMessage (user);
|
||||
ProfileBase prtu = ProfileBase.Create (model.UserName);
|
||||
prtu.SetPropertyValue("Name",model.Name);
|
||||
prtu.SetPropertyValue("Address",model.Address);
|
||||
prtu.SetPropertyValue("CityAndState",model.CityAndState);
|
||||
prtu.SetPropertyValue("Mobile",model.Mobile);
|
||||
prtu.SetPropertyValue("Phone",model.Phone);
|
||||
prtu.SetPropertyValue("ZipCode",model.ZipCode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefaultResponse ();
|
||||
}
|
||||
|
||||
|
||||
private HttpResponseMessage DefaultResponse()
|
||||
{
|
||||
return ModelState.IsValid ?
|
||||
Request.CreateResponse (System.Net.HttpStatusCode.OK) :
|
||||
Request.CreateResponse (System.Net.HttpStatusCode.BadRequest,
|
||||
ValidateAjaxAttribute.GetErrorModelObject (ModelState));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the password.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
[ValidateAjax]
|
||||
public void ResetPassword(LostPasswordModel model)
|
||||
{
|
||||
StringDictionary errors;
|
||||
YavscHelpers.ResetPassword (model, out errors);
|
||||
foreach (string key in errors.Keys)
|
||||
ModelState.AddModelError (key, errors [key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ namespace Yavsc.ApiControllers
|
|||
/// <summary>
|
||||
/// Blogs API controller.
|
||||
/// </summary>
|
||||
public class BlogsApiController : ApiController
|
||||
public class BlogsController : ApiController
|
||||
{
|
||||
private const string adminRoleName = "Admin";
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Yavsc.ApiControllers
|
|||
/// <summary>
|
||||
/// Night flash controller.
|
||||
/// </summary>
|
||||
public class CalendarApiController: ApiController
|
||||
public class CalendarController: ApiController
|
||||
{
|
||||
YaEvent[] getTestList()
|
||||
{
|
||||
|
|
@ -160,7 +160,7 @@ namespace Yavsc.ApiControllers
|
|||
"déjà enregistré");
|
||||
break;
|
||||
case MembershipCreateStatus.Success:
|
||||
YavscHelpers.SendActivationEmail (user);
|
||||
YavscHelpers.SendActivationMessage (user);
|
||||
// TODO set registration id
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,15 @@ using System.Web.Security;
|
|||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
public class NewCircle {
|
||||
public string title { get ; set; }
|
||||
public string [] users { get ; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Circle controller.
|
||||
/// </summary>
|
||||
public class CircleApiController : ApiController
|
||||
public class CircleController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the specified circle using the given title and user list.
|
||||
|
|
@ -38,10 +43,10 @@ namespace Yavsc.ApiControllers
|
|||
/// <param name="title">Identifier.</param>
|
||||
/// <param name="users">Users.</param>
|
||||
[Authorize]
|
||||
public long Create(string title, string [] users)
|
||||
public long Create(NewCircle model)
|
||||
{
|
||||
string user = Membership.GetUser ().UserName;
|
||||
return CircleManager.DefaultProvider.Create (user, title, users);
|
||||
return CircleManager.DefaultProvider.Create (user, model.title, model.users);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -164,66 +164,6 @@ namespace Yavsc.ApiControllers
|
|||
return result;
|
||||
}
|
||||
|
||||
private HttpResponseMessage DefaultResponse()
|
||||
{
|
||||
return ModelState.IsValid ?
|
||||
Request.CreateResponse (System.Net.HttpStatusCode.OK) :
|
||||
Request.CreateResponse (System.Net.HttpStatusCode.BadRequest,
|
||||
ValidateAjaxAttribute.GetErrorModelObject (ModelState));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register the specified model.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
[Authorize()]
|
||||
[ValidateAjaxAttribute]
|
||||
public HttpResponseMessage Register ([FromBody] RegisterClientModel model)
|
||||
{
|
||||
if (ModelState.IsValid) {
|
||||
if (model.IsApprouved)
|
||||
if (!Roles.IsUserInRole ("Admin"))
|
||||
if (!Roles.IsUserInRole ("FrontOffice")) {
|
||||
ModelState.AddModelError ("Register",
|
||||
"Since you're not member of Admin or FrontOffice groups, " +
|
||||
"you cannot ask for a pre-approuved registration");
|
||||
return DefaultResponse ();
|
||||
}
|
||||
MembershipCreateStatus mcs;
|
||||
var user = Membership.CreateUser (
|
||||
model.UserName,
|
||||
model.Password,
|
||||
model.Email,
|
||||
null,
|
||||
null,
|
||||
model.IsApprouved,
|
||||
out mcs);
|
||||
switch (mcs) {
|
||||
case MembershipCreateStatus.DuplicateEmail:
|
||||
ModelState.AddModelError ("Email", "Cette adresse e-mail correspond " +
|
||||
"à un compte utilisateur existant");
|
||||
break;
|
||||
case MembershipCreateStatus.DuplicateUserName:
|
||||
ModelState.AddModelError ("UserName", "Ce nom d'utilisateur est " +
|
||||
"déjà enregistré");
|
||||
break;
|
||||
case MembershipCreateStatus.Success:
|
||||
if (!model.IsApprouved)
|
||||
Yavsc.Helpers.YavscHelpers.SendActivationEmail (user);
|
||||
ProfileBase prtu = ProfileBase.Create (model.UserName);
|
||||
prtu.SetPropertyValue("Name",model.Name);
|
||||
prtu.SetPropertyValue("Address",model.Address);
|
||||
prtu.SetPropertyValue("CityAndState",model.CityAndState);
|
||||
prtu.SetPropertyValue("Mobile",model.Mobile);
|
||||
prtu.SetPropertyValue("Phone",model.Phone);
|
||||
prtu.SetPropertyValue("ZipCode",model.ZipCode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return DefaultResponse ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
33
web/ApiControllers/GCMController.cs
Normal file
33
web/ApiControllers/GCMController.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// GCMController.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
public class GCMController : ApiController
|
||||
{
|
||||
public GCMController ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
using System;
|
||||
using System.Web.Http;
|
||||
|
||||
#if HASPAYPALAPI
|
||||
#if USEPAYPALAPI
|
||||
|
||||
using PayPal.Api;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ namespace Yavsc.ApiControllers
|
|||
return ;
|
||||
case MembershipCreateStatus.Success:
|
||||
if (!userModel.IsApprouved)
|
||||
YavscHelpers.SendActivationEmail (user);
|
||||
YavscHelpers.SendActivationMessage (user);
|
||||
return;
|
||||
default:
|
||||
throw new InvalidOperationException (string.Format("Unexpected user creation code :{0}",mcs));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue