* BlogsController.cs: * refactoring

* implements a file posting, in a directory named with an user's post
  id

* BlogManager.cs:
* BlogsController.cs: Any user may edit any title
This commit is contained in:
Paul Schneider
2015-09-11 16:26:18 +02:00
parent ab4471e974
commit b45f681ae9
5 changed files with 85 additions and 31 deletions

View File

@ -179,32 +179,6 @@ namespace Yavsc.Model.Blogs
return Provider.Tag (postid, tag);
}
/// <summary>
/// Checks the auth can edit.
/// </summary>
/// <returns><c>true</c>, if can edit was authed, <c>false</c> otherwise.</returns>
/// <param name="user">User.</param>
/// <param name="title">Title.</param>
/// <param name="throwEx">If set to <c>true</c> throw ex.</param>
public static bool CheckAuthCanEdit (string user, string title, bool throwEx = true)
{
BlogEntryCollection bec = BlogManager.GetPost (user, title);
if (bec == null)
throw new FileNotFoundException ();
if (!Roles.IsUserInRole ("Admin"))
if (bec.Count > 0)
if (Membership.GetUser ().UserName != user) {
if (throwEx)
throw new AccessViolationException (
string.Format (
"Vous n'avez pas le droit d'editer ce blog (title:{0})",
title));
else
return false;
}
return true;
}
/// <summary>
/// Checks the auth can edit.
/// </summary>