Пример #1
0
        public async Task <IActionResult> Login(string username, string password, string returnUrl = null)
        {
            password = SM3.GetSM3(password);
            var admin = AdminEntity.Where(x => x.UserName == username && x.Password == password).First();

            if (admin == null)
            {
                ViewBag.errormsg = "用户名或密码错误";
                return(View());
            }
            var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);

            identity.AddClaim(new Claim(ClaimTypes.Sid, admin.Id.ToString()));
            identity.AddClaim(new Claim(ClaimTypes.Name, admin.UserName));
            identity.AddClaim(new Claim(ClaimTypes.Role, Constants.AdminRoleName));
            await AuthExtension.LoginAsync(new AdminAuthenticationAttribute(), HttpContext,
                                           new ClaimsPrincipal(identity));

            if (returnUrl != null)
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #2
0
        public IActionResult Finish(InstallModel installModel)
        {
            DbExtension.InstallDb(installModel.ToDbConfig());
            var admin = new AdminEntity();

            admin.UserName = installModel.AdminUser;
            admin.Password = SM3.GetSM3(installModel.AdminPass);
            admin.Insert();
            var settings = new List <SettingsEntity>();

            settings.Add(new SettingsEntity()
            {
                Name  = "title",
                Value = "JXCMS",
                Type  = "Settings"
            });
            settings.Add(new SettingsEntity()
            {
                Name  = "logo",
                Value = "/images/Logo.png",
                Type  = "Settings"
            });
            settings.Add(new SettingsEntity()
            {
                Name  = "keyword",
                Value = "JXCMS,急速开发CMS",
                Type  = "Settings"
            });
            settings.Add(new SettingsEntity()
            {
                Name  = "description",
                Value = "JXCMS是一款快速开发的CMS程序",
                Type  = "Settings"
            });
            settings.Add(new SettingsEntity()
            {
                Name  = "copyright",
                Value = "JXCMS 2019",
                Type  = "Settings"
            });
            settings.Add(new SettingsEntity()
            {
                Name  = "icp",
                Value = "",
                Type  = "Settings"
            });
            BaseEntity.Orm.Insert(settings).ExecuteInserted();
            System.IO.File.Create("install.lock");
            return(View());
        }