Browse Source

Fixed user password transfer not generating the new password for the transfer type.

Removed individual db.User access and replaced with user helper GetUser.
tags/2.0.3
Teknikode 4 years ago
parent
commit
e4a0bc6f8f

+ 3
- 2
Teknik/Areas/Blog/Controllers/BlogController.cs View File

@@ -9,6 +9,7 @@ using System.Web.Mvc;
using Teknik.Areas.Blog.Models;
using Teknik.Areas.Blog.ViewModels;
using Teknik.Areas.Users.Models;
using Teknik.Areas.Users.Utility;
using Teknik.Controllers;
using Teknik.Filters;
using Teknik.Helpers;
@@ -36,7 +37,7 @@ namespace Teknik.Areas.Blog.Controllers
model = new BlogViewModel();
model.BlogId = Config.BlogConfig.ServerBlogId;

User user = (User.IsInRole("Admin")) ? db.Users.Where(u => u.Username == User.Identity.Name).First() : null;
User user = (User.IsInRole("Admin")) ? UserHelper.GetUser(db, User.Identity.Name) : null;
model.UserId = (user != null) ? user.UserId : 0;
model.User = user;
model.Title = Config.BlogConfig.Title;
@@ -301,7 +302,7 @@ namespace Teknik.Areas.Blog.Controllers
{
BlogPostComment comment = db.BlogComments.Create();
comment.BlogPostId = postID;
comment.UserId = db.Users.Where(u => u.Username == User.Identity.Name).First().UserId;
comment.UserId = UserHelper.GetUser(db, User.Identity.Name).UserId;
comment.Article = article;
comment.DatePosted = DateTime.Now;
comment.DateEdited = DateTime.Now;

+ 2
- 1
Teknik/Areas/Paste/Controllers/PasteController.cs View File

@@ -8,6 +8,7 @@ using System.Web;
using System.Web.Mvc;
using Teknik.Areas.Error.Controllers;
using Teknik.Areas.Paste.ViewModels;
using Teknik.Areas.Users.Utility;
using Teknik.Controllers;
using Teknik.Filters;
using Teknik.Helpers;
@@ -127,7 +128,7 @@ namespace Teknik.Areas.Paste.Controllers

if (User.Identity.IsAuthenticated)
{
Users.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User user = UserHelper.GetUser(db, User.Identity.Name);
if (user != null)
{
paste.UserId = user.UserId;

+ 2
- 1
Teknik/Areas/Podcast/Controllers/PodcastController.cs View File

@@ -7,6 +7,7 @@ using System.Web;
using System.Web.Mvc;
using Teknik.Areas.Podcast.Models;
using Teknik.Areas.Podcast.ViewModels;
using Teknik.Areas.Users.Utility;
using Teknik.Controllers;
using Teknik.Filters;
using Teknik.Models;
@@ -358,7 +359,7 @@ namespace Teknik.Areas.Podcast.Controllers
{
PodcastComment comment = db.PodcastComments.Create();
comment.PodcastId = podcastId;
comment.UserId = db.Users.Where(u => u.Username == User.Identity.Name).First().UserId;
comment.UserId = UserHelper.GetUser(db, User.Identity.Name).UserId;
comment.Article = article;
comment.DatePosted = DateTime.Now;
comment.DateEdited = DateTime.Now;

+ 2
- 1
Teknik/Areas/Shortener/Controllers/ShortenerController.cs View File

@@ -5,6 +5,7 @@ using System.Web;
using System.Web.Mvc;
using Teknik.Areas.Shortener.Models;
using Teknik.Areas.Shortener.ViewModels;
using Teknik.Areas.Users.Utility;
using Teknik.Controllers;
using Teknik.Filters;
using Teknik.Models;
@@ -48,7 +49,7 @@ namespace Teknik.Areas.Shortener.Controllers

if (User.Identity.IsAuthenticated)
{
Users.Models.User foundUser = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User foundUser = UserHelper.GetUser(db, User.Identity.Name);
if (foundUser != null)
{
newUrl.UserId = foundUser.UserId;

+ 3
- 2
Teknik/Areas/Upload/Controllers/UploadController.cs View File

@@ -12,6 +12,7 @@ using System.Web.Mvc;
using Teknik.Areas.Error.ViewModels;
using Teknik.Areas.Upload.Models;
using Teknik.Areas.Upload.ViewModels;
using Teknik.Areas.Users.Utility;
using Teknik.Controllers;
using Teknik.Filters;
using Teknik.Helpers;
@@ -32,7 +33,7 @@ namespace Teknik.Areas.Upload.Controllers
ViewBag.Title = "Teknik Upload - End to End Encryption";
UploadViewModel model = new UploadViewModel();
model.CurrentSub = Subdomain;
Users.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User user = UserHelper.GetUser(db, User.Identity.Name);
if (user != null)
{
model.SaveKey = user.UploadSettings.SaveKey;
@@ -115,7 +116,7 @@ namespace Teknik.Areas.Upload.Controllers
{
if (User.Identity.IsAuthenticated)
{
Users.Models.User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
Users.Models.User user = UserHelper.GetUser(db, User.Identity.Name);
if (user != null)
{
upload.UserId = user.UserId;

+ 3
- 3
Teknik/Areas/User/Controllers/UserController.cs View File

@@ -43,7 +43,7 @@ namespace Teknik.Areas.Users.Controllers

try
{
User user = db.Users.Where(u => u.Username == username).FirstOrDefault();
User user = UserHelper.GetUser(db, username);

if (user != null)
{
@@ -94,7 +94,7 @@ namespace Teknik.Areas.Users.Controllers
ViewBag.Title = "User Does Not Exist - " + Config.Title;
ViewBag.Description = "The User does not exist";

User user = db.Users.Where(u => u.Username == username).FirstOrDefault();
User user = UserHelper.GetUser(db, username);

if (user != null)
{
@@ -126,7 +126,7 @@ namespace Teknik.Areas.Users.Controllers
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();
User user = UserHelper.GetUser(db, username);
if (user != null)
{
if (!string.IsNullOrEmpty(user.UserSettings.PGPSignature))

+ 1
- 5
Teknik/Areas/User/Utility/UserHelper.cs View File

@@ -263,13 +263,9 @@ namespace Teknik.Areas.Users.Utility
switch (transfer.Type)
{
case TransferTypes.Sha256Password:
user.HashedPassword = GeneratePassword(config, user, password);
break;
case TransferTypes.CaseSensitivePassword:
user.HashedPassword = GeneratePassword(config, user, password);
break;
case TransferTypes.ASCIIPassword:
user.HashedPassword = GeneratePassword(config, user, password);
user.HashedPassword = SHA384.Hash(user.Username.ToLower(), password).ToHex();
break;
default:
break;

Loading…
Cancel
Save