Browse Source

Renamed 'Profile' area to 'User' to better match it's purpose.

Added PGP Public Key adding for users and a method to view/link raw pgp key.
Updated multiple packages.
master
Teknikode 6 years ago
parent
commit
74e5e90e1b
  1. 2
      Teknik/Areas/Blog/Controllers/BlogController.cs
  2. 2
      Teknik/Areas/Blog/Models/Blog.cs
  3. 2
      Teknik/Areas/Blog/Models/BlogPostComment.cs
  4. 2
      Teknik/Areas/Blog/ViewModels/BlogViewModel.cs
  5. 2
      Teknik/Areas/Blog/ViewModels/CommentViewModel.cs
  6. 2
      Teknik/Areas/Blog/Views/Blog/Comment.cshtml
  7. 2
      Teknik/Areas/Blog/Views/Blog/Post.cshtml
  8. 27
      Teknik/Areas/Home/Controllers/HomeController.cs
  9. 4
      Teknik/Areas/Home/Views/Home/Index.cshtml
  10. 2
      Teknik/Areas/Paste/Controllers/PasteController.cs
  11. 2
      Teknik/Areas/Paste/Models/Paste.cs
  12. 2
      Teknik/Areas/Podcast/Models/PodcastComment.cs
  13. 2
      Teknik/Areas/Podcast/ViewModels/CommentViewModel.cs
  14. 2
      Teknik/Areas/Podcast/Views/Podcast/Comment.cshtml
  15. 82
      Teknik/Areas/Profile/ProfileAreaRegistration.cs
  16. 2
      Teknik/Areas/Shortener/Controllers/ShortenerController.cs
  17. 2
      Teknik/Areas/Shortener/Models/ShortenedUrl.cs
  18. 2
      Teknik/Areas/Transparency/Controllers/TransparencyController.cs
  19. 4
      Teknik/Areas/Upload/Controllers/UploadController.cs
  20. 2
      Teknik/Areas/Upload/Models/Upload.cs
  21. 45
      Teknik/Areas/User/Controllers/UserController.cs
  22. 2
      Teknik/Areas/User/Models/BlogSettings.cs
  23. 2
      Teknik/Areas/User/Models/Group.cs
  24. 2
      Teknik/Areas/User/Models/PermissionTarget.cs
  25. 2
      Teknik/Areas/User/Models/PermissionType.cs
  26. 2
      Teknik/Areas/User/Models/Role.cs
  27. 2
      Teknik/Areas/User/Models/UploadSettings.cs
  28. 2
      Teknik/Areas/User/Models/User.cs
  29. 5
      Teknik/Areas/User/Models/UserSettings.cs
  30. 2
      Teknik/Areas/User/Scripts/User.js
  31. 90
      Teknik/Areas/User/UserAreaRegistration.cs
  32. 4
      Teknik/Areas/User/Utility/UserHelper.cs
  33. 2
      Teknik/Areas/User/ViewModels/LoginViewModel.cs
  34. 4
      Teknik/Areas/User/ViewModels/ProfileViewModel.cs
  35. 4
      Teknik/Areas/User/ViewModels/RegisterViewModel.cs
  36. 4
      Teknik/Areas/User/ViewModels/SettingsViewModel.cs
  37. 56
      Teknik/Areas/User/Views/User/Index.cshtml
  38. 4
      Teknik/Areas/User/Views/User/Login.cshtml
  39. 4
      Teknik/Areas/User/Views/User/Register.cshtml
  40. 46
      Teknik/Areas/User/Views/User/Settings.cshtml
  41. 4
      Teknik/Areas/User/Views/User/ViewLogin.cshtml
  42. 4
      Teknik/Areas/User/Views/User/ViewRegistration.cshtml
  43. 0
      Teknik/Areas/User/Views/_ViewStart.cshtml
  44. 0
      Teknik/Areas/User/Views/web.config
  45. 2
      Teknik/Global.asax.cs
  46. 81
      Teknik/Helpers/Crypto.cs
  47. 23
      Teknik/Helpers/StringExtensions.cs
  48. 32
      Teknik/Migrations/Configuration.cs
  49. 2
      Teknik/Models/TeknikEntities.cs
  50. 4
      Teknik/Scripts/Common.js
  51. BIN
      Teknik/Scripts/_references.js
  52. 4
      Teknik/Scripts/jquery-2.2.0.min.js
  53. 1
      Teknik/Scripts/jquery-2.2.0.min.map
  54. 8
      Teknik/Scripts/jquery-2.2.3-vsdoc.js
  55. 111
      Teknik/Scripts/jquery-2.2.3.js
  56. 4
      Teknik/Scripts/jquery-2.2.3.min.js
  57. 1
      Teknik/Scripts/jquery-2.2.3.min.map
  58. 4
      Teknik/Scripts/jquery.validate-vsdoc.js
  59. 590
      Teknik/Scripts/jquery.validate.js
  60. 6
      Teknik/Scripts/jquery.validate.min.js
  61. 78
      Teknik/Teknik.csproj
  62. 10
      Teknik/Views/Shared/_LoginPartial.cshtml
  63. 14
      Teknik/packages.config

2
Teknik/Areas/Blog/Controllers/BlogController.cs

@ -8,7 +8,7 @@ using System.Web; @@ -8,7 +8,7 @@ using System.Web;
using System.Web.Mvc;
using Teknik.Areas.Blog.Models;
using Teknik.Areas.Blog.ViewModels;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.Controllers;
using Teknik.Helpers;
using Teknik.Models;

2
Teknik/Areas/Blog/Models/Blog.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
namespace Teknik.Areas.Blog.Models
{

2
Teknik/Areas/Blog/Models/BlogPostComment.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
namespace Teknik.Areas.Blog.Models
{

2
Teknik/Areas/Blog/ViewModels/BlogViewModel.cs

@ -4,7 +4,7 @@ using System.Linq; @@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teknik.Areas.Blog.Models;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Blog.ViewModels

2
Teknik/Areas/Blog/ViewModels/CommentViewModel.cs

@ -3,7 +3,7 @@ using System.Collections.Generic; @@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Blog.Models;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Blog.ViewModels

2
Teknik/Areas/Blog/Views/Blog/Comment.cshtml

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<div class="col-sm-8 col-sm-offset-2">
<div class="post-comment">
<p class="post-comment-meta text-muted">
<a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = Model.User.Username })">@Model.User.Username</a> replied at <time datetime="@Model.DatePosted.ToString("o")">@Model.DatePosted.ToString("hh:mm:ss tt") on @Model.DatePosted.ToString("MMMM dd, yyyy")</time>
<a href="@Url.SubRouteUrl("user", "User.Index", new { username = Model.User.Username })">@Model.User.Username</a> replied at <time datetime="@Model.DatePosted.ToString("o")">@Model.DatePosted.ToString("hh:mm:ss tt") on @Model.DatePosted.ToString("MMMM dd, yyyy")</time>
@if (Model.User.Username == User.Identity.Name || User.IsInRole("Admin"))
{
<br />

2
Teknik/Areas/Blog/Views/Blog/Post.cshtml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
@if (!Model.System)
{
<text>
by <a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = Model.Blog.User.Username })">@Model.Blog.User.Username</a>
by <a href="@Url.SubRouteUrl("user", "User.Index", new { username = Model.Blog.User.Username })">@Model.Blog.User.Username</a>
</text>
}
@if (Model.Blog.User.Username == User.Identity.Name || User.IsInRole("Admin"))

27
Teknik/Areas/Home/Controllers/HomeController.cs

@ -23,19 +23,28 @@ namespace Teknik.Areas.Home.Controllers @@ -23,19 +23,28 @@ namespace Teknik.Areas.Home.Controllers
HomeViewModel model = new HomeViewModel();
// Grab the latest site blog posts
List<BlogPost> lastSite = new List<BlogPost>();
var foundSite = db.BlogPosts.Include("Blog").Include("Blog.User").OrderByDescending(post => post.DatePosted).Where(p => p.Published && p.System).Take(5);
if (foundSite != null)
lastSite = foundSite.ToList();
if (db.BlogPosts.Count() > 0)
{
var foundSite = db.BlogPosts.Include("Blog").Include("Blog.User").OrderByDescending(post => post.DatePosted).Where(p => p.Published && p.System).Take(5);
if (foundSite != null)
lastSite = foundSite.ToList();
}
// Grab the latest user blog posts
List<BlogPost> lastPosts = new List<BlogPost>();
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").OrderByDescending(post => post.DatePosted).Where(p => p.Published && !p.System).Take(5);
if (foundPosts != null)
lastPosts = foundPosts.ToList();
if (db.BlogPosts.Count() > 0)
{
var foundPosts = db.BlogPosts.Include("Blog").Include("Blog.User").OrderByDescending(post => post.DatePosted).Where(p => p.Published && !p.System).Take(5);
if (foundPosts != null)
lastPosts = foundPosts.ToList();
}
// Grab the latest podcasts
List<Podcast.Models.Podcast> lastPods = new List<Podcast.Models.Podcast>();
var foundPods = db.Podcasts.OrderByDescending(post => post.DatePosted).Where(p => p.Published).Take(5);
if (foundPods != null)
lastPods = foundPods.ToList();
if (db.Podcasts.Count() > 0)
{
var foundPods = db.Podcasts.OrderByDescending(post => post.DatePosted).Where(p => p.Published).Take(5);
if (foundPods != null)
lastPods = foundPods.ToList();
}
model.SitePosts = lastSite;
model.Podcasts = lastPods;

4
Teknik/Areas/Home/Views/Home/Index.cshtml

@ -94,7 +94,7 @@ @@ -94,7 +94,7 @@
</div>
</div>
</a>
<a href="@Url.SubRouteUrl("profile", "Profile.Index")">
<a href="@Url.SubRouteUrl("user", "User.Index")">
<div class="col-md-3 text-center">
<br />
<i class="fa fa-sitemap fa-5x"></i>
@ -237,7 +237,7 @@ @@ -237,7 +237,7 @@
<h2 class="blog-post-title-sm text-left"><a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.BlogPostId })" id="title_@post.BlogPostId">@post.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on <time datetime="@post.DatePosted.ToString("o")">@post.DatePosted.ToString("MMMM dd, yyyy")</time> by <a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = post.Blog.User.Username })">@post.Blog.User.Username</a>
Posted on <time datetime="@post.DatePosted.ToString("o")">@post.DatePosted.ToString("MMMM dd, yyyy")</time> by <a href="@Url.SubRouteUrl("user", "User.Index", new { username = post.Blog.User.Username })">@post.Blog.User.Username</a>
</p>
</div>
</div>

2
Teknik/Areas/Paste/Controllers/PasteController.cs

@ -123,7 +123,7 @@ namespace Teknik.Areas.Paste.Controllers @@ -123,7 +123,7 @@ namespace Teknik.Areas.Paste.Controllers
if (User.Identity.IsAuthenticated)
{
Profile.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
if (user != null)
{
paste.UserId = user.UserId;

2
Teknik/Areas/Paste/Models/Paste.cs

@ -3,7 +3,7 @@ using System.Collections.Generic; @@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
namespace Teknik.Areas.Paste.Models
{

2
Teknik/Areas/Podcast/Models/PodcastComment.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
namespace Teknik.Areas.Podcast.Models
{

2
Teknik/Areas/Podcast/ViewModels/CommentViewModel.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Podcast.ViewModels

2
Teknik/Areas/Podcast/Views/Podcast/Comment.cshtml

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<div class="col-sm-8 col-sm-offset-2">
<div class="post-comment">
<p class="post-comment-meta text-muted">
<a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = Model.User.Username })">@Model.User.Username</a> replied at <time datetime="@Model.DatePosted.ToString("o")">@Model.DatePosted.ToString("hh:mm:ss tt") on @Model.DatePosted.ToString("MMMM dd, yyyy")</time>
<a href="@Url.SubRouteUrl("user", "User.Index", new { username = Model.User.Username })">@Model.User.Username</a> replied at <time datetime="@Model.DatePosted.ToString("o")">@Model.DatePosted.ToString("hh:mm:ss tt") on @Model.DatePosted.ToString("MMMM dd, yyyy")</time>
@if (Model.User.Username == User.Identity.Name || User.IsInRole("Admin"))
{
<br />

82
Teknik/Areas/Profile/ProfileAreaRegistration.cs

@ -1,82 +0,0 @@ @@ -1,82 +0,0 @@
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Optimization;
using Teknik.Configuration;
namespace Teknik.Areas.Profile
{
public class ProfileAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Profile";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
Config config = Config.Load();
context.MapSubdomainRoute(
"Profile.Login", // Route name
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Login", // URL with parameters
new { controller = "Profile", action = "Login" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile.Logout", // Route name
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Logout", // URL with parameters
new { controller = "Profile", action = "Logout" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile.Register", // Route name
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Register", // URL with parameters
new { controller = "Profile", action = "Register" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile.Settings", // Route name
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Settings", // URL with parameters
new { controller = "Profile", action = "Settings" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile.Index", // Route name
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"{username}", // URL with parameters
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile.Action", // Route name
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{action}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
// Register Script Bundle
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/profile").Include(
"~/Scripts/bootbox/bootbox.min.js",
"~/Scripts/jquery.blockUI.js",
"~/Scripts/bootstrap-switch.js",
"~/Areas/Profile/Scripts/Profile.js"));
// Register Style Bundles
BundleTable.Bundles.Add(new StyleBundle("~/Content/profile").Include(
"~/Content/bootstrap-switch/bootstrap3/bootstrap-switch.css"));
}
}
}

2
Teknik/Areas/Shortener/Controllers/ShortenerController.cs

@ -46,7 +46,7 @@ namespace Teknik.Areas.Shortener.Controllers @@ -46,7 +46,7 @@ namespace Teknik.Areas.Shortener.Controllers
if (User.Identity.IsAuthenticated)
{
Profile.Models.User foundUser = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User foundUser = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
if (foundUser != null)
{
newUrl.UserId = foundUser.UserId;

2
Teknik/Areas/Shortener/Models/ShortenedUrl.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
namespace Teknik.Areas.Shortener.Models
{

2
Teknik/Areas/Transparency/Controllers/TransparencyController.cs

@ -30,7 +30,7 @@ namespace Teknik.Areas.Transparency.Controllers @@ -30,7 +30,7 @@ namespace Teknik.Areas.Transparency.Controllers
Paste.Models.Paste paste = db.Pastes.OrderByDescending(p => p.PasteId).FirstOrDefault();
model.PasteCount = (paste != null) ? paste.PasteId : 0;
Profile.Models.User user = db.Users.OrderByDescending(u => u.UserId).FirstOrDefault();
Users.Models.User user = db.Users.OrderByDescending(u => u.UserId).FirstOrDefault();
model.UserCount = (user != null) ? user.UserId : 0;
Shortener.Models.ShortenedUrl url = db.ShortenedUrls.OrderByDescending(s => s.ShortenedUrlId).FirstOrDefault();

4
Teknik/Areas/Upload/Controllers/UploadController.cs

@ -28,7 +28,7 @@ namespace Teknik.Areas.Upload.Controllers @@ -28,7 +28,7 @@ namespace Teknik.Areas.Upload.Controllers
ViewBag.Title = "Teknik Upload - End to End Encryption";
UploadViewModel model = new UploadViewModel();
model.CurrentSub = Subdomain;
Areas.Profile.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
if (user != null)
{
model.SaveKey = user.UploadSettings.SaveKey;
@ -111,7 +111,7 @@ namespace Teknik.Areas.Upload.Controllers @@ -111,7 +111,7 @@ namespace Teknik.Areas.Upload.Controllers
{
if (User.Identity.IsAuthenticated)
{
Profile.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
if (user != null)
{
upload.UserId = user.UserId;

2
Teknik/Areas/Upload/Models/Upload.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
namespace Teknik.Areas.Upload.Models
{

45
Teknik/Areas/Profile/Controllers/ProfileController.cs → Teknik/Areas/User/Controllers/UserController.cs

@ -10,8 +10,8 @@ using Teknik.Areas.Shortener.Models; @@ -10,8 +10,8 @@ using Teknik.Areas.Shortener.Models;
using Teknik.Areas.Blog.Models;
using Teknik.Areas.Error.Controllers;
using Teknik.Areas.Error.ViewModels;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Profile.ViewModels;
using Teknik.Areas.Users.Models;
using Teknik.Areas.Users.ViewModels;
using Teknik.Controllers;
using Teknik.Helpers;
using Teknik.Models;
@ -19,9 +19,9 @@ using Teknik.ViewModels; @@ -19,9 +19,9 @@ using Teknik.ViewModels;
using System.Windows;
using System.Net;
namespace Teknik.Areas.Profile.Controllers
namespace Teknik.Areas.Users.Controllers
{
public class ProfileController : DefaultController
public class UserController : DefaultController
{
private TeknikEntities db = new TeknikEntities();
@ -67,10 +67,10 @@ namespace Teknik.Areas.Profile.Controllers @@ -67,10 +67,10 @@ namespace Teknik.Areas.Profile.Controllers
return View(model);
}
model.Error = true;
model.ErrorMessage = "The user does not exist";
return View(model);
}
// GET: Profile/Profile
[AllowAnonymous]
public ActionResult Settings()
{
@ -106,13 +106,30 @@ namespace Teknik.Areas.Profile.Controllers @@ -106,13 +106,30 @@ namespace Teknik.Areas.Profile.Controllers
[HttpGet]
[AllowAnonymous]
// GET: Profile
public ActionResult ViewRawPGP(string username)
{
ViewBag.Title = username + "'s Public Key - " + Config.Title;
ViewBag.Description = "The PGP public key for " + username;
User user = db.Users.Where(u => u.Username == username).FirstOrDefault();
if (user != null)
{
if (!string.IsNullOrEmpty(user.UserSettings.PGPSignature))
{
return Content(user.UserSettings.PGPSignature, "text/plain");
}
}
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
}
[HttpGet]
[AllowAnonymous]
public ActionResult Login(string ReturnUrl)
{
LoginViewModel model = new LoginViewModel();
model.ReturnUrl = ReturnUrl;
return View("/Areas/Profile/Views/Profile/ViewLogin.cshtml", model);
return View("/Areas/Users/Views/User/ViewLogin.cshtml", model);
}
[HttpPost]
@ -175,13 +192,12 @@ namespace Teknik.Areas.Profile.Controllers @@ -175,13 +192,12 @@ namespace Teknik.Areas.Profile.Controllers
[HttpGet]
[AllowAnonymous]
// GET: Profile
public ActionResult Register(string ReturnUrl)
{
RegisterViewModel model = new RegisterViewModel();
model.ReturnUrl = ReturnUrl;
return View("/Areas/Profile/Views/Profile/ViewRegistration.cshtml", model);
return View("/Areas/User/Views/User/ViewRegistration.cshtml", model);
}
[HttpPost]
@ -273,7 +289,7 @@ namespace Teknik.Areas.Profile.Controllers @@ -273,7 +289,7 @@ namespace Teknik.Areas.Profile.Controllers
}
[HttpPost]
public ActionResult Edit(string curPass, string newPass, string newPassConfirm, string website, string quote, string about, string blogTitle, string blogDesc, bool saveKey, bool serverSideEncrypt)
public ActionResult Edit(string curPass, string newPass, string newPassConfirm, string pgpPublicKey, string website, string quote, string about, string blogTitle, string blogDesc, bool saveKey, bool serverSideEncrypt)
{
if (ModelState.IsValid)
{
@ -328,6 +344,13 @@ namespace Teknik.Areas.Profile.Controllers @@ -328,6 +344,13 @@ namespace Teknik.Areas.Profile.Controllers
}
}
// PGP Key valid?
if (!string.IsNullOrEmpty(pgpPublicKey) && !PGP.IsPublicKey(pgpPublicKey))
{
return Json(new { error = "Invalid PGP Public Key" });
}
user.UserSettings.PGPSignature = pgpPublicKey;
user.UserSettings.Website = website;
user.UserSettings.Quote = quote;
user.UserSettings.About = about;

2
Teknik/Areas/Profile/Models/BlogSettings.cs → Teknik/Areas/User/Models/BlogSettings.cs

@ -6,7 +6,7 @@ using System.Linq; @@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public class BlogSettings
{

2
Teknik/Areas/Profile/Models/Group.cs → Teknik/Areas/User/Models/Group.cs

@ -4,7 +4,7 @@ using System.Linq; @@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public class Group
{

2
Teknik/Areas/Profile/Models/PermissionTarget.cs → Teknik/Areas/User/Models/PermissionTarget.cs

@ -4,7 +4,7 @@ using System.Linq; @@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public enum PermissionTarget
{

2
Teknik/Areas/Profile/Models/PermissionType.cs → Teknik/Areas/User/Models/PermissionType.cs

@ -4,7 +4,7 @@ using System.Linq; @@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public enum PermissionType
{

2
Teknik/Areas/Profile/Models/Role.cs → Teknik/Areas/User/Models/Role.cs

@ -4,7 +4,7 @@ using System.Linq; @@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public class Role
{

2
Teknik/Areas/Profile/Models/UploadSettings.cs → Teknik/Areas/User/Models/UploadSettings.cs

@ -6,7 +6,7 @@ using System.Linq; @@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public class UploadSettings
{

2
Teknik/Areas/Profile/Models/User.cs → Teknik/Areas/User/Models/User.cs

@ -4,7 +4,7 @@ using Microsoft.AspNet.Identity.EntityFramework; @@ -4,7 +4,7 @@ using Microsoft.AspNet.Identity.EntityFramework;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public class User
{

5
Teknik/Areas/Profile/Models/UserSettings.cs → Teknik/Areas/User/Models/UserSettings.cs

@ -6,7 +6,7 @@ using System.Linq; @@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Teknik.Areas.Profile.Models
namespace Teknik.Areas.Users.Models
{
public class UserSettings
{
@ -19,6 +19,8 @@ namespace Teknik.Areas.Profile.Models @@ -19,6 +19,8 @@ namespace Teknik.Areas.Profile.Models
public string Quote { get; set; }
public string PGPSignature { get; set; }
public virtual User User { get; set; }
public virtual BlogSettings BlogSettings { get; set; }
@ -30,6 +32,7 @@ namespace Teknik.Areas.Profile.Models @@ -30,6 +32,7 @@ namespace Teknik.Areas.Profile.Models
About = string.Empty;
Website = string.Empty;
Quote = string.Empty;
PGPSignature = string.Empty;
}
}
}

2
Teknik/Areas/Profile/Scripts/Profile.js → Teknik/Areas/User/Scripts/User.js

@ -37,6 +37,7 @@ @@ -37,6 +37,7 @@
current_password = $("#update_password_current").val();
password = $("#update_password").val();
password_confirm = $("#update_password_confirm").val();
update_pgp_public_key = $("#update_pgp_public_key").val();
website = $("#update_website").val();
quote = $("#update_quote").val();
about = $("#update_about").val();
@ -51,6 +52,7 @@ @@ -51,6 +52,7 @@
curPass: current_password,
newPass: password,
newPassConfirm: password_confirm,
pgpPublicKey: update_pgp_public_key,
website: website,
quote: quote,
about: about,

90
Teknik/Areas/User/UserAreaRegistration.cs

@ -0,0 +1,90 @@ @@ -0,0 +1,90 @@
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Optimization;
using Teknik.Configuration;
namespace Teknik.Areas.Users
{
public class UserAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "User";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
Config config = Config.Load();
context.MapSubdomainRoute(
"User.Login", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"Login", // URL with parameters
new { controller = "User", action = "Login" }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
context.MapSubdomainRoute(
"User.Logout", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"Logout", // URL with parameters
new { controller = "User", action = "Logout" }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
context.MapSubdomainRoute(
"User.Register", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"Register", // URL with parameters
new { controller = "User", action = "Register" }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
context.MapSubdomainRoute(
"User.Settings", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"Settings", // URL with parameters
new { controller = "User", action = "Settings" }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
context.MapSubdomainRoute(
"User.Index", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"{username}", // URL with parameters
new { controller = "User", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
context.MapSubdomainRoute(
"User.PGPKey", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"{username}/PGP", // URL with parameters
new { controller = "User", action = "ViewRawPGP" }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
context.MapSubdomainRoute(
"User.Action", // Route name
new List<string>() { "user" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{action}", // URL with parameters
new { controller = "User", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.UserController).Namespace }
);
// Register Script Bundle
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/user").Include(
"~/Scripts/bootbox/bootbox.min.js",
"~/Scripts/jquery.blockUI.js",
"~/Scripts/bootstrap-switch.js",
"~/Areas/User/Scripts/User.js"));
// Register Style Bundles
BundleTable.Bundles.Add(new StyleBundle("~/Content/user").Include(
"~/Content/bootstrap-switch/bootstrap3/bootstrap-switch.css"));
}
}
}

4
Teknik/Areas/Profile/Utility/UserHelper.cs → Teknik/Areas/User/Utility/UserHelper.cs

@ -5,11 +5,11 @@ using System.Text; @@ -5,11 +5,11 @@ using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Security;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.Configuration;
using Teknik.Models;
namespace Teknik.Areas.Profile.Utility
namespace Teknik.Areas.Users.Utility
{
public static class UserHelper
{

2
Teknik/Areas/Profile/ViewModels/LoginViewModel.cs → Teknik/Areas/User/ViewModels/LoginViewModel.cs

@ -8,7 +8,7 @@ using Teknik.Helpers; @@ -8,7 +8,7 @@ using Teknik.Helpers;
using Teknik.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Profile.ViewModels
namespace Teknik.Areas.Users.ViewModels
{
public class LoginViewModel : ViewModelBase
{

4
Teknik/Areas/Profile/ViewModels/ProfileViewModel.cs → Teknik/Areas/User/ViewModels/ProfileViewModel.cs

@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Profile.ViewModels
namespace Teknik.Areas.Users.ViewModels
{
public class ProfileViewModel : ViewModelBase
{

4
Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs → Teknik/Areas/User/ViewModels/RegisterViewModel.cs

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
using System;
using System.ComponentModel.DataAnnotations;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.Helpers;
using Teknik.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Profile.ViewModels
namespace Teknik.Areas.Users.ViewModels
{
public class RegisterViewModel : ViewModelBase
{

4
Teknik/Areas/Profile/ViewModels/SettingsViewModel.cs → Teknik/Areas/User/ViewModels/SettingsViewModel.cs

@ -2,10 +2,10 @@ @@ -2,10 +2,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.ViewModels;
namespace Teknik.Areas.Profile.ViewModels
namespace Teknik.Areas.Users.ViewModels
{
public class SettingsViewModel : ViewModelBase
{

56
Teknik/Areas/Profile/Views/Profile/Index.cshtml → Teknik/Areas/User/Views/User/Index.cshtml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
@model Teknik.Areas.Profile.ViewModels.ProfileViewModel
@model Teknik.Areas.Users.ViewModels.ProfileViewModel
@using Teknik.Helpers
@using Teknik.Areas.Paste
@ -8,15 +8,69 @@ @@ -8,15 +8,69 @@
@if (!Model.Error)
{
bool OwnProfile = (Model.Username == User.Identity.Name || User.IsInRole("Admin"));
string pgpFingerprint = pgpFingerprint = string.Empty;
string pgpFingerprint64 = string.Empty;
if (!string.IsNullOrEmpty(Model.UserSettings.PGPSignature))
{
pgpFingerprint = PGP.GetFingerprint(Model.UserSettings.PGPSignature);
pgpFingerprint64 = PGP.GetFingerprint64(Model.UserSettings.PGPSignature);
}
<div class="row text-center">
<div class="col-sm-3"><h1>@Model.Username</h1></div>
</div>
<div class="modal fade" id="pgpSignature" tabindex="-1" role="dialog" aria-labelledby="pgpSignatureLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="newPostLabel">@(Model.Username)'s Public Key</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-2">
Fingerprint:
</div>
<div class="col-sm-10 text-right">
@pgpFingerprint.AddStringAtInterval(4, " ")
</div>
</div>
<div class="row">
<div class="col-sm-2">
64-bit:
</div>
<div class="col-sm-10 text-right">
@pgpFingerprint64.AddStringAtInterval(4, " ")
</div>
</div>
<div class="row">
<div class="col-sm-2">
Raw:
</div>
<div class="col-sm-10 text-right">
<a href="@Url.SubRouteUrl("user", "User.PGPKey", new { username = Model.Username })" target="_blank">@Url.SubRouteUrl("user", "User.PGPKey", new { username = Model.Username })</a>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-12">
<textarea class="form-control wmd-input" name="pgpKeyBlock" id="pgpKeyBlock" title="Public Key" rows="10" onClick="SelectAll('pgpKeyBlock');" readonly>@Model.UserSettings.PGPSignature</textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<!-- Left Info Box -->
<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)
{

4
Teknik/Areas/Profile/Views/Profile/Login.cshtml → Teknik/Areas/User/Views/User/Login.cshtml

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
@model Teknik.Areas.Profile.ViewModels.LoginViewModel
@model Teknik.Areas.Users.ViewModels.LoginViewModel
@if (Model.Config.UserConfig.LoginEnabled)
{
<form role="form" id="loginForm" action="@Url.SubRouteUrl("profile", "Profile.Login")" method="post" accept-charset="UTF-8">
<form role="form" id="loginForm" action="@Url.SubRouteUrl("user", "User.Login")" method="post" accept-charset="UTF-8">
<input name="ReturnUrl" id="ReturnUrl" type="hidden" value="@Model.ReturnUrl" />
<div class="form-group">
<input type="text" class="form-control" id="Username" value="" placeholder="Username" name="Username" data-val-required="The Username field is required." data-val="true" />

4
Teknik/Areas/Profile/Views/Profile/Register.cshtml → Teknik/Areas/User/Views/User/Register.cshtml

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
@model Teknik.Areas.Profile.ViewModels.RegisterViewModel
@model Teknik.Areas.Users.ViewModels.RegisterViewModel
@if (Model.Config.UserConfig.RegistrationEnabled)
{
<form role="form" id="registrationForm" action="@Url.SubRouteUrl("profile", "Profile.Register")" method="post" accept-charset="UTF-8">
<form role="form" id="registrationForm" action="@Url.SubRouteUrl("user", "User.Register")" method="post" accept-charset="UTF-8">
<input name="ReturnUrl" id="ReturnUrl" type="hidden" value="@Model.ReturnUrl" />
<div class="form-group">
<input type="text" class="form-control" id="Username" value="" placeholder="Username" name="Username" data-val-required="The Username field is required." data-val="true"/>

46
Teknik/Areas/Profile/Views/Profile/Settings.cshtml → Teknik/Areas/User/Views/User/Settings.cshtml

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
@model Teknik.Areas.Profile.ViewModels.SettingsViewModel
@model Teknik.Areas.Users.ViewModels.SettingsViewModel
@using Teknik.Helpers
<script>
var homeUrl = '@Url.SubRouteUrl("www", "Home.Index")';
var editUserURL = '@Url.SubRouteUrl("profile", "Profile.Action", new { action = "Edit" })';
var deleteUserURL = '@Url.SubRouteUrl("profile", "Profile.Action", new { action = "Delete" })';
var editUserURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "Edit" })';
var deleteUserURL = '@Url.SubRouteUrl("user", "User.Action", new { action = "Delete" })';
</script>
@Styles.Render("~/Content/profile")
@Scripts.Render("~/bundles/profile")
@Styles.Render("~/Content/user")
@Scripts.Render("~/bundles/user")
<div class="container">
@if (!Model.Error)
@ -26,25 +26,37 @@ @@ -26,25 +26,37 @@
</div>
<hr>
<div class="row">
<div class="form-group col-sm-4">
<label for="update_password_current"><h4>Current Password</h4></label>
<input class="form-control" name="update_password_current" id="update_password_current" placeholder="current password" title="enter your current password." type="password" />
</div>
<div class="form-group col-sm-4">
<label for="update_password"><h4>New Password</h4></label>
<input class="form-control" name="update_password" id="update_password" placeholder="new password" title="enter your password." type="password" />
<div class="col-sm-4">
<div class="row">
<div class="form-group col-sm-12">
<label for="update_password_current"><h4>Current Password</h4></label>
<input class="form-control" name="update_password_current" id="update_password_current" placeholder="current password" title="enter your current password." type="password" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="update_password"><h4>New Password</h4></label>
<input class="form-control" name="update_password" id="update_password" placeholder="new password" title="enter your password." type="password" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-12">
<label for="update_password_confirm"><h4>Verify New Password</h4></label>
<input class="form-control" name="update_password_confirm" id="update_password_confirm" placeholder="new password confirmed" title="enter your password again." type="password" />
</div>
</div>
</div>
<div class="form-group col-sm-4">
<label for="update_password_confirm"><h4>Verify New Password</h4></label>
<input class="form-control" name="update_password_confirm" id="update_password_confirm" placeholder="new password confirmed" title="enter your password again." type="password" />
<div class="col-sm-8">
<label for="update_pgp_public_key"><h4>Public Key</h4></label>
<textarea class="form-control" id="update_pgp_public_key" name="update_pgp_public_key" placeholder="Public Key Here" title="enter your blog's description" rows="10">@Model.UserSettings.PGPSignature</textarea>
</div>
</div>
<div class="row">
<div class="form-group col-sm-6">
<div class="form-group col-sm-4">
<label for="update_website"><h4>Website</h4></label>
<input class="form-control" id="update_website" name="update_website" placeholder="http://www.noneofyourbusiness.com/" title="enter your website" type="text" value="@Model.UserSettings.Website" />
</div>
<div class="form-group col-sm-6">
<div class="form-group col-sm-8">
<label for="update_quote"><h4>Quote</h4></label>
<input class="form-control" id="update_quote" name="update_quote" placeholder="I have a dream!" title="enter a memorable quote" type="text" value="@Model.UserSettings.Quote" maxlength="140" />
</div>

4
Teknik/Areas/Profile/Views/Profile/ViewLogin.cshtml → Teknik/Areas/User/Views/User/ViewLogin.cshtml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
@model Teknik.Areas.Profile.ViewModels.LoginViewModel
@model Teknik.Areas.Users.ViewModels.LoginViewModel
<div class="container">
<div class="row">
@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<div class="text-center">
<h1>Teknik Login</h1>
<div class="col-md-4 col-md-offset-4">
@Html.Partial("../../Areas/Profile/Views/Profile/Login", Model)
@Html.Partial("../../Areas/User/Views/User/Login", Model)
</div>
</div>
</div>

4
Teknik/Areas/Profile/Views/Profile/ViewRegistration.cshtml → Teknik/Areas/User/Views/User/ViewRegistration.cshtml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
@model Teknik.Areas.Profile.ViewModels.RegisterViewModel
@model Teknik.Areas.Users.ViewModels.RegisterViewModel
<div class="container">
<div class="row">
@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<h1>Teknik Registration</h1>
<h3>By regsitering, you agree to Teknik's <a href="@Url.SubRouteUrl("tos", "Terms")">Terms of Service</a></h3>
<div class="col-md-4 col-md-offset-4">
@Html.Partial("../../Areas/Profile/Views/Profile/Register", Model)
@Html.Partial("../../Areas/User/Views/User/Register", Model)
</div>
</div>
</div>

0
Teknik/Areas/Profile/Views/_ViewStart.cshtml → Teknik/Areas/User/Views/_ViewStart.cshtml

0
Teknik/Areas/Profile/Views/web.config → Teknik/Areas/User/Views/web.config

2
Teknik/Global.asax.cs

@ -10,7 +10,7 @@ using System.Data.Entity; @@ -10,7 +10,7 @@ using System.Data.Entity;
using System.Web.Security;
using Teknik.Migrations;
using System.Data.Entity.Migrations;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using System.ComponentModel;
using Teknik.Areas.Error.Controllers;
using System.Web.Helpers;

81
Teknik/Helpers/Crypto.cs

@ -11,7 +11,10 @@ using Org.BouncyCastle.Crypto.Paddings; @@ -11,7 +11,10 @@ using Org.BouncyCastle.Crypto.Paddings;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities.Encoders;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Org.BouncyCastle.Utilities.IO;
using System;
using System.Collections.Generic;
namespace Teknik.Helpers
{
@ -149,4 +152,82 @@ namespace Teknik.Helpers @@ -149,4 +152,82 @@ namespace Teknik.Helpers
return keyGenerator.GetBytes(keySize / 8);
}
}
public static class PGP
{
public static bool IsPublicKey(string key)
{
bool isValid = false;
try
{
byte[] byteArray = Encoding.ASCII.GetBytes(key);
using (MemoryStream stream = new MemoryStream(byteArray))
{
using (Stream decoderStream = PgpUtilities.GetDecoderStream(stream))
{
PgpPublicKeyRingBundle publicKeyBundle = new PgpPublicKeyRingBundle(decoderStream);
PgpPublicKey foundKey = GetFirstPublicKey(publicKeyBundle);
if (foundKey != null)
{
isValid = true;
}
}
}
}
catch (Exception ex)
{
isValid = false;
}
return isValid;
}
public static string GetFingerprint(string key)
{
string hexString = string.Empty;
byte[] byteArray = Encoding.ASCII.GetBytes(key);
using (MemoryStream stream = new MemoryStream(byteArray))
{
using (Stream decoderStream = PgpUtilities.GetDecoderStream(stream))
{
PgpPublicKeyRingBundle publicKeyBundle = new PgpPublicKeyRingBundle(decoderStream);
PgpPublicKey foundKey = GetFirstPublicKey(publicKeyBundle);
if (foundKey != null)
{
byte[] fing = foundKey.GetFingerprint();
hexString = Hex.ToHexString(fing);
}
}
}
return hexString;
}
public static string GetFingerprint64(string key)
{
string fingerprint = GetFingerprint(key);
if (fingerprint.Length > 16)
fingerprint = fingerprint.Substring(fingerprint.Length - 16);
return fingerprint;
}
private static PgpPublicKey GetFirstPublicKey(PgpPublicKeyRingBundle publicKeyRingBundle)
{
foreach (PgpPublicKeyRing kRing in publicKeyRingBundle.GetKeyRings())
{
var keys = kRing.GetPublicKeys();
foreach (var key in keys)
{
PgpPublicKey foundKey = (PgpPublicKey)key;
//PgpPublicKey key = kRing.GetPublicKeys()
//.Cast<PgpPublicKey>()
// .Where(k => k.IsEncryptionKey)
// .FirstOrDefault();
if (foundKey != null && foundKey.IsEncryptionKey)
return foundKey;
}
}
return null;
}
}
}

23
Teknik/Helpers/StringExtensions.cs

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace Teknik.Helpers
@ -13,5 +14,27 @@ namespace Teknik.Helpers @@ -13,5 +14,27 @@ namespace Teknik.Helpers
return value.Length <= maxLength ? value : value.Substring(0, maxLength);
}
public static string AddStringAtInterval(this string value, int interval, string insertStr)
{
if (interval <= 0 || value.Length < interval)
return value;
StringBuilder sb = new StringBuilder();
int finalIndex = 0;
for (int i = 0; i < value.Length; i = i + interval)
{
sb.Append(value.Substring(i, interval));
sb.Append(insertStr);
finalIndex = i;
}
if (finalIndex + interval != value.Length)
{
sb.Append(value.Substring(finalIndex, value.Length - finalIndex));
}
return sb.ToString();
}
}
}

32
Teknik/Migrations/Configuration.cs

@ -27,13 +27,13 @@ namespace Teknik.Migrations @@ -27,13 +27,13 @@ namespace Teknik.Migrations
{
// Pre-populate with the default stuff
// Create system blog
Areas.Profile.Models.User systemUser = new Areas.Profile.Models.User();
Areas.Users.Models.User systemUser = new Areas.Users.Models.User();
systemUser.Username = Constants.SERVERUSER;
systemUser.JoinDate = DateTime.Now;
systemUser.LastSeen = DateTime.Now;
systemUser.UserSettings = new Areas.Profile.Models.UserSettings();
systemUser.BlogSettings = new Areas.Profile.Models.BlogSettings();
systemUser.UploadSettings = new Areas.Profile.Models.UploadSettings();
systemUser.UserSettings = new Areas.Users.Models.UserSettings();
systemUser.BlogSettings = new Areas.Users.Models.BlogSettings();
systemUser.UploadSettings = new Areas.Users.Models.UploadSettings();
context.Users.AddOrUpdate(systemUser);
context.SaveChanges();
@ -44,32 +44,32 @@ namespace Teknik.Migrations @@ -44,32 +44,32 @@ namespace Teknik.Migrations
context.SaveChanges();
// Create roles and groups
Areas.Profile.Models.Role adminRole = new Areas.Profile.Models.Role();
Areas.Users.Models.Role adminRole = new Areas.Users.Models.Role();
adminRole.Name = "Admin";
adminRole.Description = "Allows complete access to user specific actions";
context.Roles.AddOrUpdate(adminRole);
Areas.Profile.Models.Role podcastRole = new Areas.Profile.Models.Role();
Areas.Users.Models.Role podcastRole = new Areas.Users.Models.Role();
podcastRole.Name = "Podcast";
podcastRole.Description = "Allows create/edit/delete access to podcasts";
context.Roles.AddOrUpdate(podcastRole);
Areas.Profile.Models.Group adminGroup = new Areas.Profile.Models.Group();
Areas.Users.Models.Group adminGroup = new Areas.Users.Models.Group();
adminGroup.Name = "Administrators";
adminGroup.Description = "System Administrators with full access";
adminGroup.Roles = new List<Areas.Profile.Models.Role>();
adminGroup.Roles = new List<Areas.Users.Models.Role>();
adminGroup.Roles.Add(adminRole);
adminGroup.Roles.Add(podcastRole);
context.Groups.AddOrUpdate(adminGroup);
Areas.Profile.Models.Group podcastGroup = new Areas.Profile.Models.Group();
Areas.Users.Models.Group podcastGroup = new Areas.Users.Models.Group();
podcastGroup.Name = "Podcast";
podcastGroup.Description = "Podcast team members";
podcastGroup.Roles = new List<Areas.Profile.Models.Role>();
podcastGroup.Roles = new List<Areas.Users.Models.Role>();
podcastGroup.Roles.Add(podcastRole);
context.Groups.AddOrUpdate(podcastGroup);
Areas.Profile.Models.Group memberGroup = new Areas.Profile.Models.Group();
Areas.Users.Models.Group memberGroup = new Areas.Users.Models.Group();
memberGroup.Name = "Member";
memberGroup.Description = "The default member group with basic permissions";
context.Groups.AddOrUpdate(memberGroup);
@ -129,10 +129,10 @@ namespace Teknik.Migrations @@ -129,10 +129,10 @@ namespace Teknik.Migrations
foreach (var user in userRet)
{
// Create User
Areas.Profile.Models.User newUser = new Areas.Profile.Models.User();
newUser.UserSettings = new Areas.Profile.Models.UserSettings();
newUser.BlogSettings = new Areas.Profile.Models.BlogSettings();
newUser.UploadSettings = new Areas.Profile.Models.UploadSettings();
Areas.User.Models.User newUser = new Areas.User.Models.User();
newUser.UserSettings = new Areas.User.Models.UserSettings();
newUser.BlogSettings = new Areas.User.Models.BlogSettings();
newUser.UploadSettings = new Areas.User.Models.UploadSettings();
newUser.TransferAccount = true;
newUser.Username = user["username"].ToString();
newUser.HashedPassword = user["password"].ToString();
@ -151,7 +151,7 @@ namespace Teknik.Migrations @@ -151,7 +151,7 @@ namespace Teknik.Migrations
context.Users.AddOrUpdate(newUser);
context.SaveChanges();
string oldUsername = user["username"].ToString();
Areas.Profile.Models.User newUser = context.Users.Where(u => u.Username == oldUsername).FirstOrDefault();
Areas.User.Models.User newUser = context.Users.Where(u => u.Username == oldUsername).FirstOrDefault();
if (newUser != null)
{
int oldUserId = Int32.Parse(user["id"].ToString());

2
Teknik/Models/TeknikEntities.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using Teknik.Areas.Blog.Models;
using Teknik.Areas.Profile.Models;
using Teknik.Areas.Users.Models;
using Teknik.Areas.Contact.Models;
using Teknik.Migrations;
using Teknik.Areas.Upload.Models;

4
Teknik/Scripts/Common.js

@ -102,6 +102,10 @@ function getFileExtension(fileName) { @@ -102,6 +102,10 @@ function getFileExtension(fileName) {
return '.' + fileName.substr(index + 1);
}
function SelectAll(id) {
document.getElementById(id).focus();
document.getElementById(id).select();
}
/***************************** TIMER Page Load *******************************/
var loopTime;

BIN
Teknik/Scripts/_references.js

Binary file not shown.

4
Teknik/Scripts/jquery-2.2.0.min.js vendored

File diff suppressed because one or more lines are too long

1
Teknik/Scripts/jquery-2.2.0.min.map

File diff suppressed because one or more lines are too long

8
Teknik/Scripts/jquery-2.2.0-vsdoc.js → Teknik/Scripts/jquery-2.2.3-vsdoc.js vendored

@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
* intended to be used only for design-time IntelliSense. Please use the
* standard jQuery library for all runtime use.
*
* Comment version: 2.1.2
* Comment version: 2.2.3
*/
/*!
* jQuery JavaScript Library v2.1.2
* jQuery JavaScript Library v2.2.3
* http://jquery.com/
*
* Includes Sizzle.js
@ -981,7 +981,7 @@ @@ -981,7 +981,7 @@
}
};
jQuery.ajaxSettings = {
"url": 'http://localhost:25812/?ver=2.1.2&newLineMethod=xml',
"url": 'http://localhost:25812/?ver=2.2.3&newLineMethod=xml',
"type": 'GET',
"isLocal": false,
"global": true,
@ -1722,7 +1722,7 @@ @@ -1722,7 +1722,7 @@
return select(selector.replace(rtrim, "$1"), context, results, seed);
};
jQuery.fn = {
"jquery": '2.1.2',
"jquery": '2.2.3',
"selector": '',
"length": 0
};

111
Teknik/Scripts/jquery-2.2.0.js → Teknik/Scripts/jquery-2.2.3.js vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v2.2.0
* jQuery JavaScript Library v2.2.3
* http://jquery.com/
*
* Includes Sizzle.js
@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-01-08T20:02Z
* Date: 2016-04-05T19:26Z
*/
(function( global, factory ) {