* avatar, username, city from Google profile

* refactoring
This commit is contained in:
Paul Schneider
2014-12-20 02:11:51 +01:00
parent edd160ae75
commit c7f81699a4
55 changed files with 708 additions and 353 deletions

View File

@ -21,7 +21,13 @@ namespace Yavsc.Controllers
WebConfigurationManager.AppSettings ["RegistrationMessage"];
string avatarDir = "~/avatars";
/// <summary>
/// Gets or sets the avatar dir.
/// This value is past to <c>Server.MapPath</c>,
/// it should start with </c>~/</c>, and we assume it
/// to be relative to the application path.
/// </summary>
/// <value>The avatar dir.</value>
public string AvatarDir {
get { return avatarDir; }
set { avatarDir = value; }
@ -159,6 +165,17 @@ namespace Yavsc.Controllers
return View();
}
[Authorize]
public ActionResult Unregister(bool confirmed=false)
{
if (!confirmed)
return View ();
Membership.DeleteUser (
Membership.GetUser ().UserName);
return RedirectToAction ("Index","Home");
}
[Authorize]
[HttpPost]
public ActionResult ChangePassword (ChangePasswordModel model)
@ -173,6 +190,7 @@ namespace Yavsc.Controllers
if (users.Count > 0) {
MembershipUser user = Membership.GetUser (model.Username,true);
changePasswordSucceeded = user.ChangePassword (model.OldPassword, model.NewPassword);
} else {
changePasswordSucceeded = false;
@ -213,13 +231,15 @@ namespace Yavsc.Controllers
if (AvatarFile != null) {
if (AvatarFile.ContentType == "image/png") {
// byte[] img = new byte[AvatarFile.ContentLength];
// AvatarFile.InputStream.Read (img, 0, AvatarFile.ContentLength);
// model.Avatar = img;
string avdir=Server.MapPath (AvatarDir);
string avpath=Path.Combine(avdir,username+".png");
AvatarFile.SaveAs (avpath);
string avuri = avpath.Substring(
AppDomain.CurrentDomain.BaseDirectory.Length);
avuri = avuri.Replace (" ", "+");
avuri = Request.Url.Scheme + "://" + Request.Url.Authority + "/" + avuri;
HttpContext.Profile.SetPropertyValue ("avatar", avuri );
HttpContext.Profile.Save ();
} else
ModelState.AddModelError ("Avatar",
string.Format ("Image type {0} is not supported (suported formats : {1})",

View File

@ -11,6 +11,12 @@ namespace Yavsc.ApiControllers
// TODO should mostly be an API Controller
public class BasketController : ApiController
{
protected WorkFlowManager wfmgr = null;
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
{
base.Initialize (controllerContext);
wfmgr = new WorkFlowManager ();
}
/// <summary>
/// Validates the order.
///
@ -42,7 +48,7 @@ namespace Yavsc.ApiControllers
[Authorize]
public Estimate[] YourEstimates()
{
return WorkFlowManager.GetEstimates (
return wfmgr.GetEstimates (
Membership.GetUser().UserName);
}

View File

@ -18,6 +18,7 @@ using Yavsc.Model;
using Yavsc.Model.Blogs;
using Yavsc.ApiControllers;
using Yavsc.Model.RolesAndMembers;
using System.Net;
namespace Yavsc.Controllers
{
@ -234,12 +235,19 @@ namespace Yavsc.Controllers
[AcceptVerbs (HttpVerbs.Get)]
public ActionResult Avatar (string user)
{
string avpath = Path.Combine (
Server.MapPath (AvatarDir), user + ".png");
FileInfo fia = new FileInfo (avpath);
if (!fia.Exists)
fia = new FileInfo (Server.MapPath (defaultAvatar));
return File (fia.OpenRead (), defaultAvatarMimetype);
ProfileBase pr = ProfileBase.Create (user);
string avpath = (string) pr.GetPropertyValue ("avatar");
if (avpath == null) {
FileInfo fia = new FileInfo (Server.MapPath (defaultAvatar));
return File (fia.OpenRead (), defaultAvatarMimetype);
}
WebRequest wr = WebRequest.Create(avpath);
using (WebResponse resp = wr.GetResponse ()) {
using (Stream str = resp.GetResponseStream ()) {
return File (str, resp.ContentType);
}
}
}
/// <summary>

View File

@ -29,6 +29,14 @@ namespace Yavsc.ApiControllers
public class FrontOfficeController : ApiController
{
protected WorkFlowManager wfmgr = null;
protected override void Initialize (System.Web.Http.Controllers.HttpControllerContext controllerContext)
{
base.Initialize (controllerContext);
wfmgr = new WorkFlowManager ();
}
[AcceptVerbs("GET")]
public Catalog Catalog ()
{
@ -87,7 +95,7 @@ namespace Yavsc.ApiControllers
/// <param name="estid">Estid.</param>
public Estimate GetEstimate (long Id)
{
Estimate est = WorkFlowManager.ContentProvider.GetEstimate (Id);
Estimate est = wfmgr.ContentProvider.GetEstimate (Id);
return est;
}
@ -107,7 +115,7 @@ namespace Yavsc.ApiControllers
private string getEstimTex(long estimid)
{
Yavsc.templates.Estim tmpe = new Yavsc.templates.Estim();
Estimate e = WorkFlowManager.GetEstimate (estimid);
Estimate e = wfmgr.GetEstimate (estimid);
tmpe.Session = new Dictionary<string,object>();
tmpe.Session.Add ("estim", e);
@ -132,7 +140,7 @@ namespace Yavsc.ApiControllers
/// <param name="estimid">Estimid.</param>
public HttpResponseMessage GetEstimPdf(long estimid)
{
Estimate estim = WorkFlowManager.GetEstimate (estimid);
Estimate estim = wfmgr.GetEstimate (estimid);
//TODO better with pro.IsBankable && cli.IsBillable
return new HttpResponseMessage () {

View File

@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
using System.IO;
using Yavsc.Controllers;
using System.Collections.Generic;
using Yavsc.Model;
using Yavsc.Model.WorkFlow;
using WorkFlowProvider;
using System.Web.Security;
@ -21,14 +22,20 @@ namespace Yavsc.Controllers
/// </summary>
public class FrontOfficeController : Controller
{
/*
protected WorkFlowManager wfmgr = null;
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
{
base.Initialize (requestContext);
wfmgr = new WorkFlowManager ();
}
*/
[Authorize]
public ActionResult Estimates ()
{
string username = Membership.GetUser ().UserName;
return View(WorkFlowManager.GetEstimates (username));
return View(wfmgr.GetEstimates (username));
}
[Authorize]
@ -38,7 +45,7 @@ namespace Yavsc.Controllers
ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
if (submit == null) {
if (model.Id > 0) {
Estimate f = WorkFlowManager.GetEstimate (model.Id);
Estimate f = wfmgr.GetEstimate (model.Id);
if (f == null) {
ModelState.AddModelError ("Id", "Wrong Id");
return View (model);
@ -64,12 +71,12 @@ namespace Yavsc.Controllers
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
if (model.Id == 0)
model = WorkFlowManager.CreateEstimate (
model = wfmgr.CreateEstimate (
username,
model.Client, model.Title, model.Description);
else {
WorkFlowManager.UpdateEstimate (model);
model = WorkFlowManager.GetEstimate (model.Id);
wfmgr.UpdateEstimate (model);
model = wfmgr.GetEstimate (model.Id);
}
}
}

View File

@ -12,27 +12,27 @@ using System.Net;
using System.IO;
using Yavsc.Model;
using Newtonsoft.Json;
using Yavsc.Model.Google;
using Yavsc.Model.RolesAndMembers;
using System.Web.Security;
using System.Web.Profile;
namespace Yavsc.Controllers
{
public class TokenResult {
public string access_token { get; set; }
public string id_token { get; set; }
public int expires_in { get; set; }
public string token_type { get; set ; }
public string refresh_token { get; set; }
}
public class GoogleController : Controller
{
private string API_KEY="AIzaSyBV_LQHb22nGgjNvFzZwnQHjao3Q7IewRw";
// private string API_KEY="AIzaSyBV_LQHb22nGgjNvFzZwnQHjao3Q7IewRw";
private string getPeopleUri = "https://www.googleapis.com/plus/v1/people";
private string CLIENT_ID="325408689282-6bekh7p3guj4k0f3301a6frf025cnrk1.apps.googleusercontent.com";
private string CLIENT_SECRET="MaxYcvJJCs2gDGvaELZbzwfL";
string [] SCOPES = {
"openid" ,
"profile",
"email"
} ;
@ -40,43 +40,37 @@ namespace Yavsc.Controllers
string tokenUri = "https://accounts.google.com/o/oauth2/token";
string authUri = "https://accounts.google.com/o/oauth2/auth";
public void Login()
public void Login(string returnUrl)
{
if (string.IsNullOrWhiteSpace (returnUrl))
returnUrl = "/";
Random rand = new Random ();
string state = "security_token"+rand.Next (100000).ToString()+rand.Next (100000).ToString();
Session ["state"] = state;
Session ["returnUrl"] = returnUrl;
string redirectUri = Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/Auth";
string prms = String.Format("response_type=code&" +
"client_id={0}&" +
"redirect_uri={1}&" +
"scope={2}&" +
"state={3}&" +
"access_type=offline&" +
"include_granted_scopes=false",
CLIENT_ID,
redirectUri,
string.Join("%20",SCOPES),
state
);
string prms = String.Format("response_type=code&client_id={0}&redirect_uri={1}&scope={2}&state={3}&access_type=offline&include_granted_scopes=false",
CLIENT_ID, redirectUri, string.Join("%20",SCOPES), state);
WebRequest wr = WebRequest.Create(authUri+"?"+prms);
wr.Method = "GET";
// Get the response.
try {
WebResponse response = wr.GetResponse();
string resQuery = response.ResponseUri.Query;
string cont = HttpUtility.ParseQueryString(resQuery)["continue"];
Response.Redirect (cont);
}
catch (WebException we) {
Response.Redirect(we.Response.ResponseUri.AbsoluteUri);
}
}
public void Auth() {
[HttpGet]
public ActionResult Auth()
{
string returnUrl = (string) Session ["returnUrl"];
string redirectUri = Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/Auth";
string code = Request.Params ["code"];
string error = Request.Params ["error"];
@ -84,13 +78,13 @@ namespace Yavsc.Controllers
ViewData ["Message"] =
string.Format(LocalizedText.Google_error,
LocalizedText.ResourceManager.GetString(error));
return;
return View();
}
string state = Request.Params ["state"];
if (state!=null && string.Compare((string)Session ["state"],state)!=0) {
ViewData ["Message"] =
LocalizedText.ResourceManager.GetString("invalid request state");
return;
return View();
}
string postdata =
@ -112,17 +106,113 @@ namespace Yavsc.Controllers
};
using (WebResponse response = webreq.GetResponse ()) {
using (Stream responseStream = response.GetResponseStream ()) {
using (StreamReader readStream = new StreamReader (responseStream, Encoding.ASCII)) {
using (StreamReader readStream = new StreamReader (responseStream, Encoding.UTF8)) {
string responseStr = readStream.ReadToEnd ();
TokenResult res = JsonConvert.DeserializeObject<TokenResult>(responseStr);
AuthToken gat = JsonConvert.DeserializeObject<AuthToken>(responseStr);
Session ["GoogleAuthToken"] = gat;
SignIn regmod = new SignIn ();
HttpWebRequest webreppro = WebRequest.CreateHttp (getPeopleUri+"/me");
webreppro.ContentType = "application/http";
webreppro.Headers.Add (HttpRequestHeader.Authorization, gat.token_type + " " + gat.access_token);
webreppro.Method = "GET";
using (WebResponse proresp = webreppro.GetResponse ()) {
using (Stream prresponseStream = proresp.GetResponseStream ()) {
using (StreamReader readproresp = new StreamReader (prresponseStream, Encoding.UTF8)) {
string prresponseStr = readproresp.ReadToEnd ();
People me = JsonConvert.DeserializeObject<People> (prresponseStr);
// TODO use me.id to retreive an existing user
string accEmail = me.emails.Where (x => x.type == "account").First().value;
MembershipUserCollection mbrs = Membership.FindUsersByEmail (accEmail);
if (mbrs.Count == 1) {
// TODO check the google id
// just set this user as logged on
FormsAuthentication.SetAuthCookie (me.displayName, true);
Session ["returnUrl"] = null;
return Redirect (returnUrl);
}
// else create the account
regmod.Email = accEmail;
regmod.UserName = me.displayName;
Session ["me"] = me;
return Auth(regmod);
}
}
}
}
}
}
}
/// <summary>
/// Creates an account using the Google authentification.
/// </summary>
/// <param name="regmod">Regmod.</param>
[HttpPost]
public ActionResult Auth(SignIn regmod)
{
if (ModelState.IsValid) {
if (Membership.GetUser (regmod.UserName) != null) {
ModelState.AddModelError ("UserName", "This user name already is in use");
return View ();
}
string returnUrl = (string)Session ["returnUrl"];
AuthToken gat = (AuthToken)Session ["GoogleAuthToken"];
People me = (People)Session ["me"];
if (gat == null || me == null)
throw new InvalidDataException ();
Random rand = new Random ();
string passwd = rand.Next (100000).ToString () + rand.Next (100000).ToString ();
MembershipCreateStatus mcs;
Membership.CreateUser (
regmod.UserName,
passwd,
regmod.Email,
null,
null,
true,
out mcs);
switch (mcs) {
case MembershipCreateStatus.DuplicateEmail:
ModelState.AddModelError ("Email", "Cette adresse e-mail correspond " +
"à un compte utilisateur existant");
return View (regmod);
case MembershipCreateStatus.DuplicateUserName:
ModelState.AddModelError ("UserName", "Ce nom d'utilisateur est " +
"déjà enregistré");
return View (regmod);
case MembershipCreateStatus.Success:
Membership.ValidateUser (regmod.UserName, passwd);
FormsAuthentication.SetAuthCookie (regmod.UserName, true);
HttpContext.Profile.Initialize (regmod.UserName, true);
HttpContext.Profile.SetPropertyValue ("gtoken", gat.access_token);
HttpContext.Profile.SetPropertyValue ("Name", me.displayName);
// TODO use image
if (me.image != null) {
HttpContext.Profile.SetPropertyValue ("avatar", me.image.url);
}
if (me.placesLived != null) {
People.Place pplace = me.placesLived.Where (x => x.primary).First ();
if (pplace != null)
HttpContext.Profile.SetPropertyValue ("Address", pplace.value);
}
if (me.url != null)
HttpContext.Profile.SetPropertyValue ("WebSite", me.url);
HttpContext.Profile.Save ();
return Redirect (returnUrl);
}
ViewData ["returnUrl"] = returnUrl;
}
return View (regmod);
}
public void ChooseCalendar()
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Yavsc.Model;
using System.Configuration;
namespace Yavsc.Controllers
{
public class ModuleController : Controller
{
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
{
base.Initialize (requestContext);
ConfigurationManager.GetSection ("ymodules");
}
// List<IModule> modules = new List<IModule> ();
public ActionResult Index()
{
return View ();
}
}
}

View File

@ -15,7 +15,7 @@ namespace Yavsc.ApiControllers
public class WorkFlowController : ApiController
{
string adminRoleName="Admin";
protected WorkFlowManager wfmgr = null;
protected override void Initialize (HttpControllerContext controllerContext)
{
// TODO move it in a module initialization
@ -23,13 +23,14 @@ namespace Yavsc.ApiControllers
if (!Roles.RoleExists (adminRoleName)) {
Roles.CreateRole (adminRoleName);
}
wfmgr = new WorkFlowManager ();
}
[HttpGet]
[Authorize]
public Estimate CreateEstimate (string title,string client,string description)
{
return WorkFlowManager.CreateEstimate (
return wfmgr.CreateEstimate (
Membership.GetUser().UserName,client,title,description);
}
@ -37,7 +38,7 @@ namespace Yavsc.ApiControllers
[Authorize]
public void DropWritting(long wrid)
{
WorkFlowManager.DropWritting (wrid);
wfmgr.DropWritting (wrid);
}
@ -46,13 +47,13 @@ namespace Yavsc.ApiControllers
[Authorize]
public void DropEstimate(long estid)
{
WorkFlowManager.DropEstimate (estid);
wfmgr.DropEstimate (estid);
}
[HttpGet]
[Authorize]
public object Index()
{
{
// TODO inform user on its roles and alerts
string username = Membership.GetUser ().UserName;
return new { test=string.Format("Hello {0}!",username) };
@ -75,7 +76,7 @@ namespace Yavsc.ApiControllers
[ValidateAjax]
public HttpResponseMessage UpdateWritting([FromBody] Writting wr)
{
WorkFlowManager.UpdateWritting (wr);
wfmgr.UpdateWritting (wr);
return Request.CreateResponse (System.Net.HttpStatusCode.OK);
}
@ -95,7 +96,7 @@ namespace Yavsc.ApiControllers
}
try {
return Request.CreateResponse(System.Net.HttpStatusCode.OK,
WorkFlowManager.Write(estid, wr.Description,
wfmgr.Write(estid, wr.Description,
wr.UnitaryCost, wr.Count, wr.ProductReference));
}
catch (Exception ex) {

View File

@ -17,9 +17,8 @@ namespace Yavsc
{
routes.IgnoreRoute ("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute ("js/{*pathInfo}");
routes.IgnoreRoute ("Scripts/{*pathInfo}");
routes.IgnoreRoute ("Theme/{*pathInfo}");
routes.IgnoreRoute ("css/{*pathInfo}");
routes.IgnoreRoute ("images/{*pathInfo}");
routes.MapRoute (
@ -44,7 +43,6 @@ namespace Yavsc
protected void Application_Start ()
{
AreaRegistration.RegisterAllAreas ();
// add formatters : GlobalConfiguration.Configuration.Formatters.Add (new ZeroFormatter ());
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{*id}",

View File

@ -43,6 +43,10 @@
<span class="hidcom"> Page d'accueil </span>
<%= Html.ActionLink("Login", "Login", "Account", new { returnUrl=Request.Url.PathAndQuery }, new { @class="actionlink" } ) %>
<span class="hidcom">Pour pouvoir poster ou commenter</span>
<a href="<%=Request.Url.Scheme + "://" + Request.Url.Authority + "/Google/Login"%>?returnUrl=<%=ViewData["returnUrl"]%>" class="actionlink">
<img src="/images/sign-in-with-google.png" style="max-height:1.5em; max-width:6em;" alt="Google sign in">
</a>
<span class="hidcom">S'authentifier avec son compte Google+</span>
<% } else { %>
<%= Html.ActionLink(HttpContext.Current.User.Identity.Name, "Profile", "Account", null, new { @class="actionlink" }) %>
<span class="hidcom"> &Eacute;dition de votre profile </span>

View File

@ -0,0 +1,50 @@
//
// ModuleConfigurationElement.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2014 Paul Schneider
//
// 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.Configuration;
namespace Yavsc.Settings
{
public class ModuleConfigurationElement : ConfigurationElement
{
public ModuleConfigurationElement ()
{
}
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
public string Name {
get {
return (string) base ["name"];
}
set { base ["name"] = value; }
}
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
public string ClassName {
get {
return (string) base ["classname"];
}
set { base ["classname"] = value; }
}
}
}

View File

@ -0,0 +1,47 @@
//
// ModuleConfigurationElementCollection.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2014 Paul Schneider
//
// 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.Configuration;
namespace Yavsc.Settings
{
public class ModuleConfigurationElementCollection : ConfigurationElementCollection
{
public ModuleConfigurationElementCollection ()
{
}
#region implemented abstract members of ConfigurationElementCollection
protected override ConfigurationElement CreateNewElement ()
{
throw new NotImplementedException ();
}
protected override object GetElementKey (ConfigurationElement element)
{
throw new NotImplementedException ();
}
#endregion
}
}

View File

@ -0,0 +1,33 @@
//
// ModulesConfigurationSection.cs
//
// Author:
// Paul Schneider <paulschneider@free.fr>
//
// Copyright (c) 2014 Paul Schneider
//
// 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.Configuration;
namespace Yavsc.Settings
{
public class ModulesConfigurationSection : ConfigurationSection
{
public ModulesConfigurationSection ()
{
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Configuration;
namespace Yavsc
{
public class ThanksConfigurationCollection : ConfigurationElementCollection
{
protected override object GetElementKey (ConfigurationElement element)
{
return ((ThanksConfigurationElement) element).Name;
}
protected override ConfigurationElement CreateNewElement ()
{
return new ThanksConfigurationElement();
}
public ThanksConfigurationElement GetElement (string name)
{
return this.BaseGet(name) as ThanksConfigurationElement;
}
}
}

View File

@ -1,48 +0,0 @@
using System;
using System.Configuration;
namespace Yavsc
{
public class ThanksConfigurationElement : ConfigurationElement
{
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
public string Name {
get {
return (string) base ["name"];
}
set { base ["name"] = value; }
}
[ConfigurationProperty("url")]
public string Url {
get {
return (string) base ["url"];
}
set { base ["url"] = value; }
}
[ConfigurationProperty("image")]
public string Image {
get {
return (string) base ["image"];
}
set { base ["image"] = value; }
}
/// <summary>
/// Gets or sets the display.
/// </summary>
/// <value>
/// The displaied text when no image is provided and we
/// don't want use the name attribute.
/// </value>
[ConfigurationProperty("display")]
public string Display {
get {
return (string) base ["display"];
}
set { base ["display"] = value; }
}
}
}

View File

@ -1,39 +0,0 @@
using System;
using System.Configuration;
namespace Yavsc
{
public class ThanksConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("to")]
public ThanksConfigurationCollection To {
get {
return (ThanksConfigurationCollection) this["to"];
}
set {
this ["to"] = value;
}
}
[ConfigurationProperty("html_class")]
public string HtmlClass {
get {
return (string)this ["html_class"];
}
set {
this ["html_class"] = value;
}
}
[ConfigurationProperty("title_format")]
public string TitleFormat {
get {
return (string)this ["title_format"];
}
set {
this ["title_format"] = value;
}
}
}
}

View File

@ -1,43 +0,0 @@
using System;
using System.Configuration;
using System.Collections.Generic;
namespace Yavsc
{
public static class ThanksHelper {
static private ThanksConfigurationSection configurationSection=null;
static public ThanksConfigurationSection ConfigurationSection {
get {
if (configurationSection==null)
configurationSection = (ThanksConfigurationSection) ConfigurationManager.GetSection ("system.web/thanks");
return configurationSection;
}
}
public static string[] Links ()
{
List<string> result = new List<string>() ;
if (ConfigurationSection == null) return result.ToArray();
if (ConfigurationSection.To == null) return result.ToArray();
foreach (ThanksConfigurationElement e in ConfigurationSection.To) {
string link = "";
if (!string.IsNullOrEmpty(e.Url))
link = string.Format("<a href=\"{0}\">",e.Url);
string dsp = (string.IsNullOrEmpty(e.Display))?e.Name:e.Display;
if (!string.IsNullOrEmpty(e.Image)) {
string ttl = (string.IsNullOrEmpty(ConfigurationSection.TitleFormat))?"Go and see the website ({0})":ConfigurationSection.TitleFormat;
ttl = string.Format(ttl,dsp);
link += string.Format(
"<img src=\"{1}\" alt=\"{0}\" title=\"{2}\"/>",
dsp,e.Image,ttl);
}
else link += dsp;
if (e.Url!=null)
link += "</a> ";
result.Add (link);
}
return result.ToArray();
}
}
}

View File

@ -3,4 +3,4 @@
<h2>Comptes utilisteur</h2>
</asp:Content>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
</asp:Content>
</asp:Content>

View File

@ -19,5 +19,5 @@
<input type="submit"/>
<% } %>
<%= Html.ActionLink("S'enregistrer","Register",new {returnUrl=ViewData["returnUrl"]}) %>
<%= Html.ActionLink("S'enregistrer","Register",new {returnUrl=ViewData["returnUrl"]}, new { @class="actionlink" }) %>
</asp:Content>

View File

@ -1,10 +0,0 @@
<%@ Page Title="Login" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
<%= Html.ValidationSummary("Ouverture de session avec OpenID") %>
<% using(Html.BeginForm("OpenIDLogOn", "Account")) %>
<% { %>
<label for="loginIdentifier"/>
<%= Html.TextBox( "loginIdentifier" ) %>
<%= Html.ValidationMessage("loginIdentifier", "*") %>
<% } %>
</asp:Content>

View File

@ -52,10 +52,16 @@
<%= Html.TextBox("BlogTitle") %>
<%= Html.ValidationMessage("BlogTitle", "*") %></td></tr>
<tr><td align="right">
Avatar </td><td> <img class="avatar" src="/Blogs/Avatar?user=<%=ViewData["UserName"]%>" alt=""/>
Avatar </td><td> <img class="avatar" src="<%=Model.avatar%>" alt=""/>
<input type="file" id="AvatarFile" name="AvatarFile"/>
<%= Html.ValidationMessage("AvatarFile", "*") %></td></tr>
<tr><td align="right">
<%= Html.LabelFor(model => model.GoogleCalendar) %>
</td>
<td>
</td>
</tr>
</table>
<h2>Informations de facturation</h2>
@ -132,8 +138,6 @@ Avatar </td><td> <img class="avatar" src="/Blogs/Avatar?user=<%=ViewData["User
Bankable:<%= Model.IsBankable %>, Billable:<%=Model.IsBillable%>
<% } %>
<%= Html.ActionLink("Changer de mot de passe","ChangePassword", "Account")%>
</asp:Content>
<%= Html.ActionLink("Changer de mot de passe","ChangePassword", "Account",null, new { @class="actionlink" })%>
<%= Html.ActionLink("Désincription","Unregister", "Account",null, new { @class="actionlink" })%>
</asp:Content>

View File

@ -0,0 +1,11 @@

<%@ Page Title="Unregister" Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Models/App.master" %>
<asp:Content ContentPlaceHolderID="MainContent" ID="MainContentContent" runat="server">
Warning: This will delete all of your data here, your profile, your posts and other data.
<% using(Html.BeginForm("Unregister", "Account")) { %>
<label for="confirmed">Unregister</label>
<%=Html.CheckBox("confirmed")%>
<input type="submit"/>
<% } %>
</asp:Content>

View File

@ -1,7 +1,7 @@
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<BlogEditEntryModel>" MasterPageFile="~/Models/App.master"%>
<asp:Content ContentPlaceHolderID="head" ID="head1" runat="server" >
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript" src="/js/rangyinputs-jquery-1.1.2.js"></script>
<script type="text/javascript" src="/Scripts/jquery-2.1.1.js"></script>
<script type="text/javascript" src="/Scripts/rangyinputs-jquery-1.1.2.js"></script>
</asp:Content>
<asp:Content ContentPlaceHolderID="overHeaderOne" ID="headerContent" runat="server">
<h1 class="blogtitle">

View File

@ -1,10 +1,10 @@
<%@ Page Title="Devis" Language="C#" Inherits="System.Web.Mvc.ViewPage<Estimate>" MasterPageFile="~/Models/App.master" %>
<asp:Content ContentPlaceHolderID="head" ID="head1" runat="server" >
<script type="text/javascript" src="<%=Url.Content("~/js/jquery-latest.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/js/jquery.tablesorter.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/js/jquery.validate.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/js/jquery.validate.unobtrusive.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery-2.1.1.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery.tablesorter.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery.validate.js")%>"></script>
<script type="text/javascript" src="<%=Url.Content("~/Scripts/jquery.validate.unobtrusive.js")%>"></script>
<link rel="stylesheet" href="<%=Url.Content("~/Theme/dark/style.css")%>" type="text/css" media="print, projection, screen" />
</asp:Content>

View File

@ -79,21 +79,22 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<add assembly="Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
<add assembly="Npgsql, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
<add assembly="System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="Microsoft.Build.Utilities.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Json, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<customErrors mode="Off" />
@ -173,6 +174,11 @@ http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
<add name="WicketCode" />
<add name="AccountNumber" />
<add name="BankedKey" />
<add name="gtoken" />
<add name="grefreshtoken" />
<add name="gtokentype" />
<add name="gtokenexpir" />
<add name="avatar" />
</properties>
</profile>
<blog defaultProvider="NpgsqlBlogProvider">

View File

@ -9,7 +9,7 @@
<ProjectTypeGuids>{349C5851-65DF-11DA-9384-00065B846F21};{603C0E0B-DB56-11DC-BE95-000D561079B0};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Yavsc</RootNamespace>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -78,12 +78,6 @@
<Reference Include="Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.Build.Utilities.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Web.Http.WebHost">
<HintPath>..\..\..\..\..\usr\lib\mono\4.5\System.Web.Http.WebHost.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Formatting">
<HintPath>..\..\..\..\..\usr\lib\mono\4.5\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
@ -92,15 +86,16 @@
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web.Mvc" />
<Reference Include="System.Web.Http" />
<Reference Include="System.Net.Http.Formatting" />
<Reference Include="System.Web.Http.WebHost" />
<Reference Include="System.Json" />
<Reference Include="System.Web.WebPages" />
<Reference Include="System.Web.WebPages.Deployment" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
<Folder Include="Scripts\" />
<Folder Include="Views\Account\" />
<Folder Include="images\" />
<Folder Include="Thanks\" />
<Folder Include="Views\Blogs\" />
<Folder Include="Helpers\" />
<Folder Include="Views\FrontOffice\" />
@ -112,7 +107,6 @@
<Folder Include="CatExts\" />
<Folder Include="Views\WorkFlow\" />
<Folder Include="Views\Admin\" />
<Folder Include="js\" />
<Folder Include="Theme\" />
<Folder Include="Theme\green\" />
<Folder Include="Theme\blue\" />
@ -122,6 +116,7 @@
<Folder Include="install\" />
<Folder Include="App_GlobalResources\" />
<Folder Include="Views\Google\" />
<Folder Include="Settings\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\HomeController.cs" />
@ -129,10 +124,6 @@
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Controllers\AccountController.cs" />
<Compile Include="Thanks\ThanksConfigurationSection.cs" />
<Compile Include="Thanks\ThanksConfigurationCollection.cs" />
<Compile Include="Thanks\ThanksConfigurationElement.cs" />
<Compile Include="Thanks\ThanksHelper.cs" />
<Compile Include="Controllers\BlogsController.cs" />
<Compile Include="Views\RegisterPage.cs" />
<Compile Include="AssemblyInfo.cs" />
@ -165,6 +156,14 @@
<Compile Include="Controllers\FormInputValue.cs" />
<Compile Include="Controllers\IValueProvider.cs" />
<Compile Include="Controllers\GoogleController.cs" />
<Compile Include="Controllers\ModuleController.cs" />
<Compile Include="Settings\ThanksConfigurationSection.cs" />
<Compile Include="Settings\ThanksConfigurationCollection.cs" />
<Compile Include="Settings\ThanksConfigurationElement.cs" />
<Compile Include="Settings\ThanksHelper.cs" />
<Compile Include="Settings\ModulesConfigurationSection.cs" />
<Compile Include="Settings\ModuleConfigurationElementCollection.cs" />
<Compile Include="Settings\ModuleConfigurationElement.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Web.config" />
@ -223,10 +222,6 @@
<Content Include="Views\Admin\Restored.aspx" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Views\FrontOffice\Estimate.aspx" />
<Content Include="js\jquery.metadata.js" />
<Content Include="js\jquery.tablesorter.js" />
<Content Include="js\jquery.tablesorter.min.js" />
<Content Include="js\jquery-latest.js" />
<Content Include="Theme\style.css" />
<Content Include="Theme\green\asc.png" />
<Content Include="Theme\green\bg.png" />
@ -243,19 +238,23 @@
<Content Include="Views\FrontOffice\Estimates.aspx" />
<Content Include="images\pgsql.png" />
<Content Include="Views\Home\ReferencedAssemblies.aspx" />
<Content Include="js\rangyinputs-jquery-1.1.2.js" />
<Content Include="Catalog.xml" />
<Content Include="RegistrationMail.txt" />
<Content Include="instdbws.sql" />
<Content Include="Views\FrontOffice\Writting.ascx" />
<Content Include="packages.config" />
<Content Include="Views\Account\OpenIDLogOn.aspx" />
<Content Include="Views\Google\Calendar.aspx" />
<Content Include="Views\Google\Login.aspx" />
<Content Include="Scripts\jquery-2.1.1-vsdoc.js" />
<Content Include="Scripts\jquery-2.1.1.js" />
<Content Include="Scripts\jquery-2.1.1.min.js" />
<Content Include="Views\Google\Auth.aspx" />
<Content Include="Scripts\jquery.metadata.js" />
<Content Include="Scripts\jquery.tablesorter.js" />
<Content Include="Scripts\jquery.tablesorter.min.js" />
<Content Include="Scripts\rangyinputs-jquery-1.1.2.js" />
<Content Include="images\sign-in-with-google.png" />
<Content Include="Views\Account\Unregister.aspx" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
@ -272,7 +271,6 @@
</ProjectExtensions>
<ItemGroup>
<None Include="README" />
<None Include="uninstdb.sql" />
<None Include="uninstdbws.sql" />
<None Include="templates\Estim.tt">
<Generator>TextTemplatingFilePreprocessor</Generator>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -249,8 +249,13 @@ CREATE TABLE profiledata
wicketcode character varying(5),
iban character varying(33),
bic character varying(15),
gcode character varying(512),
CONSTRAINT fkprofiles2 FOREIGN KEY (uniqueid)
gtoken character varying(512),
grefreshtoken character varying(512), -- Google refresh token
gtokentype character varying(256), -- Google access token type
gcalid character varying(255),
gtokenexpir timestamp with time zone, -- Google access token expiration date
avatar character varying(512), -- url for an avatar
CONSTRAINT fkprofiles2 FOREIGN KEY (uniqueid)
REFERENCES profiles (uniqueid) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
)
@ -264,9 +269,14 @@ COMMENT ON COLUMN profiledata.hasavatar IS 'True when user has specified an imag
COMMENT ON COLUMN profiledata.accountnumber IS 'Numero de compte';
COMMENT ON COLUMN profiledata.bankedkey IS 'clé RIB';
COMMENT ON COLUMN profiledata.bankcode IS 'Code banque';
COMMENT ON COLUMN profiledata.gtoken IS 'Google authentification token';
COMMENT ON COLUMN profiledata.gcalid IS 'Google calendar identifier';
COMMENT ON COLUMN profiledata.gtokentype IS 'Google access token type';
COMMENT ON COLUMN profiledata.grefreshtoken IS 'Google refresh token';
COMMENT ON COLUMN profiledata.gtokenexpir IS 'Google access token expiration date';
COMMENT ON COLUMN profiledata.avatar IS 'url for an avatar';
-- Index: fki_fkprofiles2
-- Index: fki_fkprofiles2
-- DROP INDEX fki_fkprofiles2;

File diff suppressed because one or more lines are too long

View File

@ -1,6 +0,0 @@
DROP TABLE hr;
DROP TABLE taskdeps;
DROP TABLE tasks;
DROP TABLE projet;