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:
parent
74e5e90e1b
commit
d9e9a488fe
@ -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]
|
||||
|
@ -34,6 +34,11 @@ namespace Teknik.Areas.Blog.ViewModels
|
||||
|
||||
public List<BlogPostComment> Comments { get; set; }
|
||||
|
||||
public PostViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PostViewModel(BlogPost post)
|
||||
{
|
||||
BlogId = post.BlogId;
|
||||
|
@ -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>
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user