mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Fixed user password transfer not generating the new password for the transfer type.
Removed individual db.User access and replaced with user helper GetUser.
This commit is contained in:
parent
e4b2ab0afc
commit
e4a0bc6f8f
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
|
@ -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…
Reference in New Issue
Block a user