Browse Source

Added case sensitivity to certain model properties, and added a more robust transfer account system.

tags/2.0.3
Teknikode 3 years ago
parent
commit
5e88144bbf

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

@@ -64,7 +64,8 @@ namespace Teknik.Areas.Paste.Controllers
// The paste has a password set
if (!string.IsNullOrEmpty(paste.HashedPassword))
{
if (string.IsNullOrEmpty(password) || Helpers.SHA384.Hash(paste.Key, password) != paste.HashedPassword)
string hashedPass = Helpers.SHA384.Hash(paste.Key, password).ToHex();
if (string.IsNullOrEmpty(password) || hashedPass != paste.HashedPassword)
{
PasswordViewModel passModel = new PasswordViewModel();
passModel.Url = url;

+ 5
- 0
Teknik/Areas/Paste/Models/Paste.cs View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Teknik.Areas.Users.Models;
using Teknik.Attributes;

namespace Teknik.Areas.Paste.Models
{
@@ -17,6 +18,7 @@ namespace Teknik.Areas.Paste.Models

public DateTime DatePosted { get; set; }

[CaseSensitive]
public string Url { get; set; }

public string Content { get; set; }
@@ -27,12 +29,15 @@ namespace Teknik.Areas.Paste.Models

public DateTime? ExpireDate { get; set; }

[CaseSensitive]
public string HashedPassword { get; set; }

[CaseSensitive]
public string Key { get; set; }

public int KeySize { get; set; }

[CaseSensitive]
public string IV { get; set; }

public int BlockSize { get; set; }

+ 1
- 1
Teknik/Areas/Paste/PasteHelper.cs View File

@@ -60,7 +60,7 @@ namespace Teknik.Areas.Paste
{
string key = Utility.RandomString(config.PasteConfig.KeySize / 8);
string iv = Utility.RandomString(config.PasteConfig.BlockSize / 16);
paste.HashedPassword = Helpers.SHA384.Hash(key, password);
paste.HashedPassword = SHA384.Hash(key, password).ToHex();

// Encrypt Content
byte[] data = Encoding.Unicode.GetBytes(content);

+ 3
- 1
Teknik/Areas/Shortener/Models/ShortenedUrl.cs View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Users.Models;
using Teknik.Attributes;

namespace Teknik.Areas.Shortener.Models
{
@@ -13,7 +14,8 @@ namespace Teknik.Areas.Shortener.Models
public int? UserId { get; set; }

public User User { get; set; }

[CaseSensitive]
public string ShortUrl { get; set; }
public string OriginalUrl { get; set; }

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

@@ -173,7 +173,7 @@ namespace Teknik.Areas.Upload.Controllers
// Check to see if they have a cache
bool isCached = !string.IsNullOrEmpty(Request.Headers["If-Modified-Since"]);

if (isCached && !byRange)
if (isCached)
{
// The file is cached, let's just 304 this
Response.StatusCode = 304;

+ 6
- 0
Teknik/Areas/Upload/Models/Upload.cs View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using Teknik.Areas.Users.Models;
using Teknik.Attributes;

namespace Teknik.Areas.Upload.Models
{
@@ -16,22 +17,27 @@ namespace Teknik.Areas.Upload.Models

public DateTime DateUploaded { get; set; }

[CaseSensitive]
public string Url { get; set; }

[CaseSensitive]
public string FileName { get; set; }

public int ContentLength { get; set; }

public string ContentType { get; set; }

[CaseSensitive]
public string Key { get; set; }

[CaseSensitive]
public string IV { get; set; }

public int KeySize { get; set; }

public int BlockSize { get; set; }

[CaseSensitive]
public string DeleteKey { get; set; }

public int Downloads { get; set; }

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

@@ -155,22 +155,13 @@ namespace Teknik.Areas.Users.Controllers
if (ModelState.IsValid)
{
string username = model.Username;
string password = SHA384.Hash(model.Username, model.Password);
User user = db.Users.Where(b => b.Username == username).FirstOrDefault();
User user = UserHelper.GetUser(db, username);
if (user != null)
{
if (user.TransferAccount)
{
password = SHA256.Hash(model.Password, Config.Salt1, Config.Salt2);
}
bool userValid = db.Users.Any(b => b.Username == username && b.HashedPassword == password);
bool userValid = UserHelper.UserPasswordCorrect(db, Config, user, model.Password);
if (userValid)
{
if (user.TransferAccount)
{
user.HashedPassword = SHA384.Hash(model.Username, model.Password);
user.TransferAccount = false;
}
UserHelper.TransferUser(db, Config, user, model.Password);
user.LastSeen = DateTime.Now;
db.Entry(user).State = EntityState.Modified;
db.SaveChanges();
@@ -296,7 +287,7 @@ namespace Teknik.Areas.Users.Controllers
if (!string.IsNullOrEmpty(curPass) && (!string.IsNullOrEmpty(newPass) || !string.IsNullOrEmpty(newPassConfirm)))
{
// Old Password Valid?
if (SHA384.Hash(User.Identity.Name, curPass) != user.HashedPassword)
if (!UserHelper.UserPasswordCorrect(db, Config, user, curPass))
{
return Json(new { error = "Invalid Original Password." });
}

+ 0
- 15
Teknik/Areas/User/Models/PermissionTarget.cs View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Areas.Users.Models
{
public enum PermissionTarget
{
Blog,
User,
Profile
}
}

+ 0
- 15
Teknik/Areas/User/Models/PermissionType.cs View File

@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Teknik.Areas.Users.Models
{
public enum PermissionType
{
Add,
Edit,
Delete
}
}

+ 24
- 0
Teknik/Areas/User/Models/TransferTypes.cs View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Teknik.Areas.Users.Models
{
public enum TransferTypes
{
Sha256Password = 0,
CaseSensitivePassword = 1,
ASCIIPassword = 2
}

public class TransferType
{
public int TransferTypeId { get; set; }

public TransferTypes Type { get; set; }

public List<User> Users { get; set; }
}
}

+ 5
- 0
Teknik/Areas/User/Models/User.cs View File

@@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Identity.EntityFramework;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Teknik.Attributes;

namespace Teknik.Areas.Users.Models
{
@@ -12,6 +13,7 @@ namespace Teknik.Areas.Users.Models
public string Username { get; set; }

[CaseSensitive]
public string HashedPassword { get; set; }

public string RecoveryEmail { get; set; }
@@ -20,6 +22,8 @@ namespace Teknik.Areas.Users.Models

public bool TransferAccount { get; set; }

public List<TransferType> Transfers { get; set; }

public DateTime JoinDate { get; set; }

public DateTime LastSeen { get; set; }
@@ -42,6 +46,7 @@ namespace Teknik.Areas.Users.Models
HashedPassword = string.Empty;
RecoveryEmail = string.Empty;
RecoveryVerified = false;
Transfers = new List<TransferType>();
JoinDate = DateTime.Now;
LastSeen = DateTime.Now;
Groups = new List<Group>();

+ 80
- 3
Teknik/Areas/User/Utility/UserHelper.cs View File

@@ -104,6 +104,36 @@ namespace Teknik.Areas.Users.Utility
}
}

public static string GeneratePassword(Config config, User user, string password)
{
try
{
string username = user.Username.ToLower();
if (user.Transfers.Exists(t => t.Type == TransferTypes.CaseSensitivePassword))
{
username = user.Username;
}
byte[] hashBytes = SHA384.Hash(username, password);
string hash = hashBytes.ToHex();

if (user.Transfers.Exists(t => t.Type == TransferTypes.ASCIIPassword))
{
hash = Encoding.ASCII.GetString(hashBytes);
}

if (user.Transfers.Exists(t => t.Type == TransferTypes.Sha256Password))
{
hash = SHA256.Hash(password, config.Salt1, config.Salt2);
}

return hash;
}
catch (Exception ex)
{
throw new Exception("Unable to generate password.", ex);
}
}

public static void AddAccount(TeknikEntities db, Config config, User user, string password)
{
try
@@ -170,7 +200,7 @@ namespace Teknik.Areas.Users.Utility
#region User Management
public static User GetUser(TeknikEntities db, string username)
{
User user = db.Users.Where(b => b.Username == username).FirstOrDefault();
User user = db.Users.Include("Transfers").Where(b => b.Username == username).FirstOrDefault();
if (user != null)
{
user.UserSettings = db.UserSettings.Find(user.UserId);
@@ -209,12 +239,59 @@ namespace Teknik.Areas.Users.Utility
}
}

public static bool UserPasswordCorrect(TeknikEntities db, Config config, User user, string password)
{
try
{
string hash = GeneratePassword(config, user, password);
return db.Users.Any(b => b.Username == user.Username && b.HashedPassword == hash);
}
catch (Exception ex)
{
throw new Exception("Unable to determine if password is correct.", ex);
}
}

public static void TransferUser(TeknikEntities db, Config config, User user, string password)
{
try
{
List<TransferType> transfers = user.Transfers;
for (int i = 0; i < transfers.Count; i++)
{
TransferType transfer = transfers[i];
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);
break;
default:
break;
}
user.Transfers.Remove(transfer);
i--;
}
db.Entry(user).State = EntityState.Modified;
db.SaveChanges();
}
catch (Exception ex)
{
throw new Exception("Unable to transfer user info.", ex);
}
}

public static void AddUser(TeknikEntities db, Config config, User user, string password)
{
try
{
// Add User
user.HashedPassword = SHA384.Hash(user.Username, password);
user.HashedPassword = GeneratePassword(config, user, password);
db.Users.Add(user);
db.SaveChanges();

@@ -238,7 +315,7 @@ namespace Teknik.Areas.Users.Utility
if (changePass)
{
// Update User password
user.HashedPassword = SHA384.Hash(user.Username, password);
user.HashedPassword = SHA384.Hash(user.Username.ToLower(), password).ToHex();
}
db.Entry(user).State = EntityState.Modified;
db.SaveChanges();

+ 17
- 0
Teknik/Attributes/EntityAttribute.cs View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Teknik.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class CaseSensitiveAttribute : Attribute
{
public CaseSensitiveAttribute()
{
IsEnabled = true;
}
public bool IsEnabled { get; set; }
}
}

+ 4
- 5
Teknik/Helpers/Crypto.cs View File

@@ -43,14 +43,13 @@ namespace Teknik.Helpers

public class SHA384
{
public static string Hash(string key, string value)
public static byte[] Hash(string key, string value)
{
byte[] keyBytes = Encoding.ASCII.GetBytes(key);
byte[] data = Encoding.ASCII.GetBytes(value);
byte[] keyBytes = Encoding.UTF8.GetBytes(key);
byte[] data = Encoding.UTF8.GetBytes(value);

byte[] result = new HMAC2(HashFactories.SHA384, keyBytes).ComputeHash(data);

return Encoding.ASCII.GetString(result);
return result;
}
}


+ 10
- 0
Teknik/Helpers/Utility.cs View File

@@ -147,5 +147,15 @@ namespace Teknik
// Return formatted number with suffix
return readable.ToString("0.### ") + suffix;
}

public static string ToHex(this byte[] bytes)
{
string hashString = string.Empty;
foreach (byte x in bytes)
{
hashString += String.Format("{0:x2}", x);
}
return hashString;
}
}
}

+ 3
- 253
Teknik/Migrations/Configuration.cs View File

@@ -75,261 +75,11 @@ namespace Teknik.Migrations
context.Groups.AddOrUpdate(memberGroup);

context.SaveChanges();

/*
if (config.DatabaseConfig.Migrate)
{

// Convert legacy MySQL DB to new MS SQL DB
MysqlDatabase db = new MysqlDatabase(config.DatabaseConfig);
db.MysqlErrorEvent += Db_MysqlErrorEvent;
config.DatabaseConfig.Migrate = false;
Config.Save(config);

// Transfer transactions
var transRet = db.Query("SELECT * FROM `transactions`");
foreach (var tran in transRet)
{
switch (tran["trans_type"].ToString())
{
case "One-Time":
Areas.Transparency.Models.OneTime tr = new Areas.Transparency.Models.OneTime();
tr.DateSent = DateTime.Parse(tran["date_posted"].ToString());
tr.Amount = Double.Parse(tran["amount"].ToString());
tr.Currency = tran["currency"].ToString();
tr.Recipient = tran["recipient"].ToString();
tr.Reason = tran["reason"].ToString();
context.Transactions.AddOrUpdate(tr);
break;
case "Bill":
Areas.Transparency.Models.Bill bill = new Areas.Transparency.Models.Bill();
bill.DateSent = DateTime.Parse(tran["date_posted"].ToString());
bill.Amount = Double.Parse(tran["amount"].ToString());
bill.Currency = tran["currency"].ToString();
bill.Recipient = tran["recipient"].ToString();
bill.Reason = tran["reason"].ToString();
context.Transactions.AddOrUpdate(bill);
break;
case "Donation":
Areas.Transparency.Models.Donation don = new Areas.Transparency.Models.Donation();
don.DateSent = DateTime.Parse(tran["date_posted"].ToString());
don.Amount = Double.Parse(tran["amount"].ToString());
don.Currency = tran["currency"].ToString();
don.Sender = tran["sender"].ToString();
don.Reason = tran["reason"].ToString();
context.Transactions.AddOrUpdate(don);
break;
}
}
context.SaveChanges();
// Transfer Users and Blogs/Posts
Dictionary<int, int> userMapping = new Dictionary<int, int>();
Dictionary<int, int> postMapping = new Dictionary<int, int>();
var userRet = db.Query("SELECT * FROM `users`");
foreach (var user in userRet)
{
// Create User
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();
newUser.JoinDate = DateTime.Parse(user["join_date"].ToString());
newUser.LastSeen = DateTime.Parse(user["join_date"].ToString());
newUser.UserSettings.About = user["about"].ToString();
newUser.UserSettings.Website = user["website"].ToString();
newUser.UserSettings.Quote = user["quote"].ToString();
newUser.BlogSettings.Title = user["blog_title"].ToString();
newUser.BlogSettings.Description = user["blog_desc"].ToString();
if (user["site_admin"].ToString() == "1")
{
newUser.Groups.Add(adminGroup);
}

context.Users.AddOrUpdate(newUser);
context.SaveChanges();
string oldUsername = user["username"].ToString();
Areas.User.Models.User newUser = context.Users.Where(u => u.Username == oldUsername).FirstOrDefault();
if (newUser != null)
{
int oldUserId = Int32.Parse(user["id"].ToString());
int userId = newUser.UserId;

userMapping.Add(oldUserId, userId);
}
// Create Blog for user
Areas.Blog.Models.Blog newBlog = new Areas.Blog.Models.Blog();
newBlog.UserId = userId;
context.Blogs.AddOrUpdate(newBlog);
context.SaveChanges();
int blogId = newBlog.BlogId;

// Transfer Blog Posts
var postRet = db.Query("SELECT * FROM `blog` WHERE `author_id` = {0}", new object[] { oldUserId });
if (postRet != null)
{
foreach (var post in postRet)
{
// Create new Blog Post
Areas.Blog.Models.BlogPost newPost = new Areas.Blog.Models.BlogPost();
if (post["user_id"].ToString() == "0")
{
newPost.BlogId = config.BlogConfig.ServerBlogId;
newPost.System = true;
}
else
{
newPost.BlogId = blogId;
}
newPost.DatePosted = DateTime.Parse(post["date_posted"].ToString());
DateTime publishDate = DateTime.Now;
DateTime.TryParse(post["date_published"].ToString(), out publishDate);
if (publishDate < newPost.DatePosted)
{
publishDate = newPost.DatePosted;
}
newPost.DatePublished = publishDate;
newPost.DateEdited = publishDate;
newPost.Published = (post["published"].ToString() == "True");
newPost.Title = post["title"].ToString();
newPost.Article = post["post"].ToString();
context.BlogPosts.AddOrUpdate(newPost);
context.SaveChanges();
postMapping.Add(Int32.Parse(post["id"].ToString()), newPost.BlogPostId);
}
}
}
// Transfer Blog Comments
var commentRet = db.Query("SELECT * FROM `comments` WHERE `service` = {0}", new object[] { "blog" });
foreach (var comment in commentRet)
{
int postId = Int32.Parse(comment["reply_id"].ToString());
int userId = Int32.Parse(comment["user_id"].ToString());
if (postMapping.ContainsKey(postId) && userMapping.ContainsKey(userId))
{
Areas.Blog.Models.BlogPostComment newComment = new Areas.Blog.Models.BlogPostComment();
newComment.BlogPostId = postMapping[postId];
newComment.UserId = userMapping[userId];
newComment.Article = comment["post"].ToString();
newComment.DatePosted = DateTime.Parse(comment["date_posted"].ToString());
newComment.DateEdited = DateTime.Parse(comment["date_posted"].ToString());
context.BlogComments.AddOrUpdate(newComment);
context.SaveChanges();
}
}

// Transfer Pastes
var pasteRet = db.Query("SELECT * FROM `paste`");
foreach (var paste in pasteRet)
{
string pass = paste["password"].ToString();
// If it's a password protected paste, we just skip it
if (string.IsNullOrEmpty(pass) || pass == "EMPTY")
{
string content = paste["code"].ToString();
string title = paste["title"].ToString();
DateTime posted = DateTime.Parse(paste["posted"].ToString());
int userId = Int32.Parse(paste["user_id"].ToString());
Areas.Paste.Models.Paste newPaste = PasteHelper.CreatePaste(content, title);
newPaste.DatePosted = posted;
newPaste.Url = paste["pid"].ToString();
if (userMapping.ContainsKey(userId) && userId != 0)
{
newPaste.UserId = userMapping[userId];
}
context.Pastes.AddOrUpdate(newPaste);
context.SaveChanges();
}
}
// Transfer Uploads
var uploadRet = db.Query("SELECT * FROM `uploads`");
var curUploads = context.Uploads.ToList();
if (curUploads == null)
curUploads = new List<Areas.Upload.Models.Upload>();
int curUpload = 0;
int curFinished = 0;
//int curDeleted = 0;
foreach (var upload in uploadRet)
{
curUpload++;
try {
string url = upload["url"].ToString();
//Areas.Upload.Models.Upload upFound = curUploads.Find(u => u.Url == url);
//if (upFound != null)
//{
// string subDir = upFound.FileName[0].ToString();
// string filePath = Path.Combine(config.UploadConfig.UploadDirectory, subDir, upFound.FileName);
// if (File.Exists(filePath))
// {
// continue;
// }
// else
// {
// curDeleted++;
// context.Uploads.Remove(upFound);
// context.SaveChanges();
// }
//}
string fileType = upload["type"].ToString();
int contentLength = Int32.Parse(upload["filesize"].ToString());
string deleteKey = upload["delete_key"].ToString();
int userId = Int32.Parse(upload["user_id"].ToString());
DateTime uploadDate = DateTime.Parse(upload["upload_date"].ToString());
string fullUrl = string.Format("https://u.teknik.io/{0}", url);
string fileExt = Path.GetExtension(fullUrl);
if (!File.Exists(Path.Combine("Z:\\Uploads_Old", upload["filename"].ToString())))
{
continue;
}
// Download the old file and re-upload it
using (WebDownload client = new WebDownload(10000))
{
byte[] fileData;
try
{
fileData = client.DownloadData(fullUrl);
}
catch (Exception ex) {
continue;
}
try
{
// Generate key and iv if empty
string key = Utility.RandomString(config.UploadConfig.KeySize / 8);
string iv = Utility.RandomString(config.UploadConfig.BlockSize / 8);

fileData = AES.Encrypt(fileData, key, iv);
if (fileData == null || fileData.Length <= 0)
{
continue;
}
Areas.Upload.Models.Upload up = Uploader.SaveFile(fileData, fileType, contentLength, fileExt, iv, key, config.UploadConfig.KeySize, config.UploadConfig.BlockSize);
if (userMapping.ContainsKey(userId))
up.UserId = userMapping[userId];
if (!string.IsNullOrEmpty(deleteKey))
up.DeleteKey = deleteKey;
up.Url = url;
context.Entry(up).State = EntityState.Modified;
context.SaveChanges();
curFinished++;
}
catch (Exception ex) {
}
}
}
catch (Exception ex) {
}
}
//}
*/
{
}
}
}

//private void Db_MysqlErrorEvent(object sender, string e)
//{
// throw new NotImplementedException();
//}
}
}

+ 29
- 0
Teknik/Migrations/SetCaseSensitivity.sql View File

@@ -0,0 +1,29 @@
-- Uploads
ALTER TABLE Uploads
ALTER COLUMN [Url] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Uploads
ALTER COLUMN [FileName] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Uploads
ALTER COLUMN [Key] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Uploads
ALTER COLUMN [IV] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Uploads
ALTER COLUMN [DeleteKey] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL

-- Users
ALTER TABLE Users
ALTER COLUMN [HashedPassword] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL

-- Pastes
ALTER TABLE Pastes
ALTER COLUMN [Url] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Pastes
ALTER COLUMN [HashedPassword] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Pastes
ALTER COLUMN [Key] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
ALTER TABLE Pastes
ALTER COLUMN [IV] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL

-- Shortened Urls
ALTER TABLE ShortenedUrls
ALTER COLUMN [ShortUrl] NVARCHAR(MAX) COLLATE SQL_Latin1_General_CP1_CS_AS NULL

+ 10
- 0
Teknik/Models/TeknikEntities.cs View File

@@ -10,6 +10,9 @@ using Teknik.Areas.Paste.Models;
using Teknik.Areas.Podcast.Models;
using Teknik.Areas.Transparency.Models;
using Teknik.Areas.Shortener.Models;
using Teknik.Attributes;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;

namespace Teknik.Models
{
@@ -19,6 +22,7 @@ namespace Teknik.Models
public DbSet<User> Users { get; set; }
public DbSet<Group> Groups { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<TransferType> TransferTypes { get; set; }
public DbSet<RecoveryEmailVerification> RecoveryEmailVerifications { get; set; }
public DbSet<ResetPasswordVerification> ResetPasswordVerifications { get; set; }
// User Settings
@@ -92,6 +96,7 @@ namespace Teknik.Models
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<Group>().ToTable("Groups");
modelBuilder.Entity<Role>().ToTable("Roles");
modelBuilder.Entity<TransferType>().ToTable("TransferTypes");
modelBuilder.Entity<RecoveryEmailVerification>().ToTable("RecoveryEmailVerifications");
modelBuilder.Entity<ResetPasswordVerification>().ToTable("ResetPasswordVerifications");
// User Settings
@@ -118,6 +123,11 @@ namespace Teknik.Models
// Shortened Urls
modelBuilder.Entity<ShortenedUrl>().ToTable("ShortenedUrls");

// Custom Attributes
modelBuilder.Conventions.Add(new AttributeToColumnAnnotationConvention<CaseSensitiveAttribute, bool>(
"CaseSensitive",
(property, attributes) => attributes.Single().IsEnabled));

base.OnModelCreating(modelBuilder);
}
}

+ 2
- 2
Teknik/Teknik.csproj View File

@@ -211,6 +211,7 @@
<Compile Include="Areas\User\Models\BlogSettings.cs" />
<Compile Include="Areas\User\Models\ResetPasswordVerification.cs" />
<Compile Include="Areas\User\Models\RecoveryEmailVerification.cs" />
<Compile Include="Areas\User\Models\TransferTypes.cs" />
<Compile Include="Areas\User\Models\UploadSettings.cs" />
<Compile Include="Areas\User\Models\UserSettings.cs" />
<Compile Include="Areas\User\UserAreaRegistration.cs" />
@@ -256,6 +257,7 @@
<Compile Include="Areas\Vault\Models\VaultItem.cs" />
<Compile Include="Areas\Vault\VaultAreaRegistration.cs" />
<Compile Include="Areas\Vault\ViewModels\VaultViewModel.cs" />
<Compile Include="Attributes\EntityAttribute.cs" />
<Compile Include="Configuration\PiwikConfig.cs" />
<Compile Include="Configuration\ShortenerConfig.cs" />
<Compile Include="Configuration\TransparencyConfig.cs" />
@@ -284,8 +286,6 @@
<Compile Include="Helpers\Constants.cs" />
<Compile Include="Helpers\Crypto.cs" />
<Compile Include="Areas\User\Models\Group.cs" />
<Compile Include="Areas\User\Models\PermissionTarget.cs" />
<Compile Include="Areas\User\Models\PermissionType.cs" />
<Compile Include="Areas\Blog\Models\BlogPost.cs" />
<Compile Include="Areas\User\Models\Role.cs" />
<Compile Include="Helpers\ExceptionExtensions.cs" />

Loading…
Cancel
Save