1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

Fixed exception on bad post ID for blogs.

Re-ordered pgp key on profile.
This commit is contained in:
Uncled1023 2016-05-14 21:36:29 -07:00
parent 74e5e90e1b
commit d9e9a488fe
5 changed files with 19 additions and 13 deletions

View File

@ -81,13 +81,14 @@ namespace Teknik.Areas.Blog.Controllers
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
PostViewModel model = new PostViewModel();
// find the post specified
bool isAuth = User.IsInRole("Admin");
var post = db.BlogPosts.Include("Blog").Include("Blog.User").Where(p => (p.Blog.User.Username == username && p.BlogPostId == id) &&
(p.Published || p.Blog.User.Username == User.Identity.Name || isAuth)).FirstOrDefault();
if (post != null)
{
PostViewModel model = new PostViewModel(post);
model = new PostViewModel(post);
if (post.System)
{
@ -106,7 +107,9 @@ namespace Teknik.Areas.Blog.Controllers
}
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", null);
model.Error = true;
model.ErrorMessage = "Blog Post does not exist.";
return View("~/Areas/Blog/Views/Blog/ViewPost.cshtml", model);
}
[HttpPost]

View File

@ -34,6 +34,11 @@ namespace Teknik.Areas.Blog.ViewModels
public List<BlogPostComment> Comments { get; set; }
public PostViewModel()
{
}
public PostViewModel(BlogPost post)
{
BlogId = post.BlogId;

View File

@ -26,7 +26,7 @@
@Scripts.Render("~/bundles/blog")
<div class="container">
@if (Model != null)
@if (!Model.Error)
{
if (User.IsInRole("Admin") || Model.Blog.User.Username == User.Identity.Name)
{
@ -148,7 +148,7 @@ else
{
<div class="row">
<div class="col-sm-12 text-center">
<h2>That post does not exist</h2>
<h2>@Model.ErrorMessage</h2>
</div>
</div>
}

View File

@ -22,7 +22,7 @@ namespace Teknik.Areas.Stream.Controllers
[HttpGet]
[AllowAnonymous]
public ActionResult ViewStream(int id)
public FileStreamResult ViewStream(int id)
{
try
{
@ -40,14 +40,12 @@ namespace Teknik.Areas.Stream.Controllers
return File(fileResp.GetResponseStream(), fileResp.ContentType);
}
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
}
return Redirect(Url.SubRouteUrl("error", "Error.Http403"));
}
catch (Exception ex)
catch (Exception)
{
return Redirect(Url.SubRouteUrl("error", "Error.Exception", new { exception = ex }));
}
return null;
}
}
}

View File

@ -67,15 +67,15 @@
<div class="col-sm-3"><!--left col-->
<ul class="list-group">
<li class="list-group-item text-muted">Profile</li>
@if (!string.IsNullOrEmpty(pgpFingerprint))
{
<li class="list-group-item text-right"><span class="pull-left"><strong>Public Key</strong></span> <a href="#" data-toggle="modal" data-target="#pgpSignature">@pgpFingerprint64.AddStringAtInterval(4, " ")</a></li>
}
<li class="list-group-item text-right"><span class="pull-left"><strong>Joined</strong></span> <time datetime="@Model.LastSeen.ToString("o")">@Model.JoinDate.ToString("MMMM dd, yyyy")</time></li>
@if (OwnProfile && User.Identity.IsAuthenticated)
{
<li class="list-group-item text-right"><span class="pull-left"><strong>Last Seen</strong></span> <time datetime="@Model.LastSeen.ToString("o")">@Model.LastSeen.ToString("MMMM dd, yyyy")</time></li>
}
@if (!string.IsNullOrEmpty(pgpFingerprint))
{
<li class="list-group-item text-right"><span class="pull-left"><strong>Public Key</strong></span> <a href="#" data-toggle="modal" data-target="#pgpSignature">@pgpFingerprint64.AddStringAtInterval(4, " ")</a></li>
}
@if (!string.IsNullOrEmpty(Model.Email))
{
<li class="list-group-item text-right"><span class="pull-left"><strong>Email</strong></span> <a href="mailto:@Model.Email">@Model.Email</a></li>