Exemplo n.º 1
0
        public ActionResult TryChangePassword(string old_password, string new_password, string new_password_1)
        {
            if (Accounts.AccountManager.CurrentUser == null)
            {
                return(RedirectToAction(nameof(Login)));
            }
            var userName = Accounts.AccountManager.CurrentUser.Name;

            if (new_password != new_password_1)
            {
                return(RedirectToAction(nameof(ChangePassword), new { fail = true }));
            }
            using (var db = new Database.AgileBoardDBManager())
            {
                if (Accounts.AccountManager.CurrentUser.PasswordHash != Support.CryptHelper.SHA1(old_password))
                {
                    return(RedirectToAction(nameof(ChangePassword), new { fail = true }));
                }
                db.UserDBController.ChangePassword(userName, Support.CryptHelper.SHA1(new_password));
            }
            if (Accounts.AccountManager.Login(userName, new_password))
            {
                return(RedirectToAction(nameof(ChangePassword), new { success = true }));
            }
            return(RedirectToAction(nameof(ChangePassword), new { fail = true }));
        }
Exemplo n.º 2
0
 public bool MoveRight(int taskid)
 {
     using (var db = new Database.AgileBoardDBManager())
     {
         return(db.TaskDBController.IncrementStage(taskid));
     }
 }
Exemplo n.º 3
0
 public bool RemoveTask(int taskid)
 {
     using (var db = new Database.AgileBoardDBManager())
     {
         return(db.TaskDBController.Remove(taskid));
     }
 }
Exemplo n.º 4
0
 public ActionResult Archive()
 {
     if (Accounts.AccountManager.CurrentUser == null)
     {
         return(RedirectToAction(nameof(Login)));
     }
     using (var db = new Database.AgileBoardDBManager())
     {
         List <Database.Tables.Task> model = db.TaskDBController.GetAll().ToList().Where(t => t.UserId == Accounts.AccountManager.CurrentUser?.Id && t.Stage == 3).ToList();
         return(View(model));
     }
 }
Exemplo n.º 5
0
 public ActionResult Users()
 {
     if (Accounts.AccountManager.CurrentUser == null || Accounts.AccountManager.CurrentUser?.Role?.IsAdmin == false)
     {
         return(RedirectToAction(nameof(Index)));
     }
     using (var db = new Database.AgileBoardDBManager())
     {
         var model = db.UserDBController.GetAll().ToList();
         return(View(model));
     }
 }
Exemplo n.º 6
0
 public bool RemoveUser(int id)
 {
     using (var db = new Database.AgileBoardDBManager())
     {
         var usr = db.UserDBController.GetById(id);
         if (usr == null)
         {
             return(false);
         }
         return(db.UserDBController.Delete(usr.Name));
     }
 }
Exemplo n.º 7
0
 public bool AddTask([FromBody] AddTaskRequest task)
 {
     using (var db = new Database.AgileBoardDBManager())
     {
         return(db.TaskDBController.Add(new Database.Tables.Task()
         {
             Title = task.Title,
             Markdown = System.Web.HttpUtility.HtmlEncode(task.Body),
             HasImage = false,
             Stage = 0,
             UserId = Accounts.AccountManager.CurrentUser.Id,
             ImageUrl = null
         }));
     }
 }
Exemplo n.º 8
0
        public static bool Register(string Name, string Password)
        {
            if (String.IsNullOrEmpty(Name))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(Password))
            {
                return(false);
            }

            using (var db = new Database.AgileBoardDBManager())
            {
                if (db.UserDBController.Get(Name) == null)
                {
                    db.UserDBController.Add(Name, Support.CryptHelper.SHA1(Password), "User");
                    return(Login(Name, Password));
                }
                return(false);
            }
        }
Exemplo n.º 9
0
        public static bool Login(string Name, string Password)
        {
            if (String.IsNullOrEmpty(Name))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(Password))
            {
                return(false);
            }

            using (var db = new Database.AgileBoardDBManager())
            {
                User SearchResut;
                if (db.UserDBController.CheckLogin(Name, Support.CryptHelper.SHA1(Password), out SearchResut))
                {
                    CurrentUser = SearchResut;
                    return(true);
                }
                return(false);
            }
        }