public bool TrySignIn(string user, string pass, bool remindMe)
        {
            bool result = false;

            GanzAdminDbEngine db     = GanzAdminDbEngine.Instance;
            Member            member = db.Members.FindOne(m => m.Username.ToLower() == user.ToLower());

            if (member != null && member.Password == GanzUtils.Sha256(pass))
            {
                this.SignIn(member, remindMe ? 30 : 1, remindMe);
                result = true;
            }

            return(result);
        }
Example #2
0
 protected void DeleteUploadedFile(string contentPath)
 {
     try
     {
         string fullPath = GanzUtils.ProperPathCombine('\\', this.WebHost.WebRootPath, contentPath);
         if (File.Exists(fullPath))
         {
             File.Delete(fullPath);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
        public async Task <IActionResult> UploadFiles(IFormFile[] files, string currentDirectory)
        {
            try
            {
                string result = "";

                if (HttpContext.Request.Form.Files.Any())
                {
                    foreach (var file in HttpContext.Request.Form.Files)
                    {
                        string requestedPath = "\\";

                        if (currentDirectory != null)
                        {
                        }

                        string filename = DateTime.Now.ToString("yyMMdd_HHmm") + "_" + file.FileName;
                        string path     = GanzUtils.ProperPathCombine('\\', environment.WebRootPath, "content\\uploads", requestedPath, filename);

                        using (FileStream stream = new FileStream(path, FileMode.Create))
                        {
                            await file.CopyToAsync(stream);
                        }

                        result = $"{{ \"success\" : 1, \"file\": {{ \"url\" : \"./content/uploads/{requestedPath}/{filename}\" }} }}";
                    }

                    return(this.StatusCode(200, result));
                }
                else
                {
                }

                return(this.StatusCode(404));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(500, ex.Message));
            }
        }
        public void EnsureCreated()
        {
            Member adminMember = this.Members.FindOne(m => m.Username == "sa");

            if (adminMember == null)
            {
                this.Members.Insert(new Member()
                {
                    Active    = true,
                    Address   = "1039 Budapest Hímző utca 11.",
                    Name      = "SuperAdmin",
                    PaidUntil = DateTime.Now.AddYears(100),
                    Password  = GanzUtils.Sha256("admin"),
                    Phone     = "+3699 999 9999",
                    Username  = "******",
                    Roles     = new List <string>()
                    {
                        Permissions.Overlord,
                    }
                });
            }

            this.m_InnerDb.Checkpoint();
        }