mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added GetUser and UserExists helpers.
This commit is contained in:
parent
25373918a8
commit
37ab1e2eb3
@ -189,8 +189,7 @@ namespace Teknik.Areas.Profile.Controllers
|
||||
{
|
||||
if (Config.UserConfig.RegistrationEnabled)
|
||||
{
|
||||
var foundUser = db.Users.Where(b => b.Username == model.Username).FirstOrDefault();
|
||||
if (foundUser != null)
|
||||
if (Utility.UserHelper.UserExists(model.Username))
|
||||
{
|
||||
return Json(new { error = "That username already exists." });
|
||||
}
|
||||
@ -275,7 +274,7 @@ namespace Teknik.Areas.Profile.Controllers
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
User user = db.Users.Where(u => u.Username == User.Identity.Name).First();
|
||||
User user = Utility.UserHelper.GetUser(User.Identity.Name);
|
||||
if (user != null)
|
||||
{
|
||||
string email = string.Format("{0}@{1}", User.Identity.Name, Config.EmailConfig.Domain);
|
||||
@ -427,7 +426,7 @@ namespace Teknik.Areas.Profile.Controllers
|
||||
}
|
||||
|
||||
// Delete User
|
||||
User user = db.Users.Where(u => u.Username == User.Identity.Name).FirstOrDefault();
|
||||
User user = Utility.UserHelper.GetUser(User.Identity.Name);
|
||||
if (user != null)
|
||||
{
|
||||
user.UserSettings = db.UserSettings.Find(user.UserId);
|
||||
|
@ -24,16 +24,13 @@ namespace Teknik.Areas.Profile.Utility
|
||||
|
||||
public static bool UserExists(string username)
|
||||
{
|
||||
TeknikEntities db = new TeknikEntities();
|
||||
bool exists = false;
|
||||
|
||||
User user = db.Users.Where(b => b.Username == username).FirstOrDefault();
|
||||
User user = GetUser(username);
|
||||
if (user != null)
|
||||
{
|
||||
exists = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return exists;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static HttpCookie CreateAuthCookie(string username, bool remember, string domain, bool local)
|
||||
|
Loading…
Reference in New Issue
Block a user