Exemple #1
0
        //// GET: /Prsn/MyAccess
        //public ActionResult MyAccess()
        //{
        //    return RedirectToAction("Index","AspNetUsers");
        //}


        internal async Task <bool> WaitAsynchronouslyRstPwd(AspNetUser usname, string Pwd)
        {
            RoleActions roleActions = new RoleActions();
            bool        r           = await roleActions.RstPwd_forPrsn(usname, Pwd);

            return(r);
        }
Exemple #2
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
            //FacebookConfig.Register(GlobalFacebookConfiguration.Configuration);
            FacebookConfig.Register(GlobalFacebookConfiguration.Configuration);
            //GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            // Initialize the product database.
            // Database.SetInitializer(new ProductDatabaseInitializer());

            //Database.SetInitializer<ProductContext>(
            //										new DropCreateDatabaseAlways<ProductContext>());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #3
0
        // GET: AspNetUsers/UsrLock/5

        public async Task <ActionResult> UsrLock(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AspNetUser aspNetUser = await db.AspNetUsers.FindAsync(id);

            if (aspNetUser == null)
            {
                return(HttpNotFound());
            }
            var manager = new UserManager();
            var r       = await manager.FindByIdAsync(id);

            RoleActions roleActions = new RoleActions();

            if (roleActions.AdminName != r.UserName)
            {
                var z = manager.SetLockoutEnabled(r.Id, true);
                for (int i = 1; i <= manager.MaxFailedAccessAttemptsBeforeLockout; i++)
                {
                    await manager.AccessFailedAsync(r.Id);
                }
            }

            return(RedirectToAction("Index"));
        }
Exemple #4
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code, der beim Anwendungsstart ausgeführt wird
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Add custom routes
            // RegisterCustomRoutes(RouteTable.Routes);

            string pathRoot =
                @"E:\";
            //Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            //Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            string newPath = Path.Combine(pathRoot, @"Visual Studio 2013\codeplex\bcm\src\BCM.DAL\App_Data");

            AppDomain.CurrentDomain.SetData(Common.Constants.DataDirectory, newPath);

            // Automatic database updates on startup
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <ApplicationDbContext, Configuration>());

            // Add user
            ApplicationDbContext context = new ApplicationDbContext();

            RoleActions.createAdmin(context);
            RoleActions.createUserAndRole(context);
        }
Exemple #5
0
        protected void CreateUser_OnClick(object sender, EventArgs e)
        {
            if (IsValid)
            {
                var manager = new UserManager();
                var user    = new ApplicationUser()
                {
                    UserName = tbUserName.Text,
                    Email    = tbEmail.Text
                };
                IdentityResult result = manager.Create(user, tbPassword.Text);
                if (result.Succeeded)
                {
                    RoleActions roleActions = new RoleActions();
                    roleActions.AddClient(user.Id, "", "", "", "", ddlCountry.SelectedItem.Text, "");

                    IdentityHelper.SignIn(manager, user, isPersistent: false);
                    IdentityHelper.RedirectToReturnUrl("~/Portfolio", Response);
                }
                else
                {
                    FailureText.Text     = result.Errors.FirstOrDefault();
                    ErrorMessage.Visible = true;
                }
            }
        }
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
            var user          = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text, Name = NameText.Text, Type = "Patient"
            };
            IdentityResult result = manager.Create(user, Password.Text);

            RoleActions r = new RoleActions();

            r.AddRole(user, "patient");

            if (result.Succeeded)
            {
                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                //string code = manager.GenerateEmailConfirmationToken(user.Id);
                //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
                //manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
Exemple #7
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            //Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
            CssManager.CssResourceMapping.AddDefinition("juice-ui", new CssResourceDefinition
            {
                Path      = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-lightness/jquery-ui.css",
                DebugPath = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-lightness/jquery-ui.css"
            });

            MetaModel DefaultModel = new MetaModel();

            DefaultModel.RegisterContext(new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(
                                             () => new ProductContext()),
                                         new ContextConfiguration {
                ScaffoldAllTables = false
            });
        }
Exemple #8
0
        // POST: api/user
        public IHttpActionResult Post(HttpRequestMessage request, [FromBody] RoleModel value)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Executing call in debug mode");
            }

            var headers = request.Headers;

            //Check the request object to see if they passed a userId
            if (headers.Contains("userid"))
            {
                var user = headers.GetValues("userid").First();
                _log.InfoFormat("Handling POST request from user: {0}", user);

                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid data."));
                }
                try
                {
                    RoleActions roleActions = new RoleActions();

                    roleActions.Insert(value, user);
                    return(Ok());
                }
                catch (Exception e)
                {
                    _log.Error("An error occurred while adding Role.", e);
                    return(InternalServerError(e));
                }
            }

            return(BadRequest("Header value <userid> not found."));
        }
Exemple #9
0
        protected void Application_Start(object sender, EventArgs e)
        {
            Database.SetInitializer(new BazaArtikalaInit());

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #10
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // add admin user
            Models.ApplicationDbContext context = new ApplicationDbContext();
            IdentityResult IdRoleResult;
            IdentityResult IdUserResult;

            // Create a RoleStore object by using the ApplicationDbContext object.
            // The RoleStore is only allowed to contain IdentityRole objects.
            var roleStore = new RoleStore <IdentityRole>(context);

            // Create a RoleManager object that is only allowed to contain IdentityRole objects.
            // When creating the RoleManager object, you pass in (as a parameter) a new RoleStore object.
            var roleMgr = new RoleManager <IdentityRole>(roleStore);

            // Then, create the role if it doesn't already exist.
            if (!roleMgr.RoleExists("admin"))
            {
                IdRoleResult = roleMgr.Create(new IdentityRole {
                    Name = "admin"
                });
            }

            // Create a UserManager object based on the UserStore object and the ApplicationDbContext
            // object. Note that you can create new objects and use them as parameters in
            // a single line of code, rather than using multiple lines of code, as you did
            // for the RoleManager object.
            var userMgr = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var appUser = new ApplicationUser
            {
                UserName = "******",
                Email    = "*****@*****.**",
                Type     = "Admin",
                Name     = "Admin"
            };

            IdUserResult = userMgr.Create(appUser, "Pa$$word1");

            // If the new "admin" user was successfully created,
            // add the "admin" user to the "admin" role.
            if (!userMgr.IsInRole(userMgr.FindByEmail(appUser.Email).Id, "admin"))
            {
                IdUserResult = userMgr.AddToRole(userMgr.FindByEmail(appUser.Email).Id, "admin");
            }
            // Create the roles and users.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "admin", "Admin", "Admin");
            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "user", "Mary Riley", "Hygienist");
            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "user", "Dan Johnson", "Doctor");
            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "patient", "Ryan Jessen", "Patient");
        }
Exemple #11
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserandRole();
        }
Exemple #12
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Database.SetInitializer(new ProductDatabaseInitializer());
            RoleActions roleActions = new RoleActions();

            roleActions.createAdmin();
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // ADDED to create the Administrator and user roles
            RoleActions roleActions = new RoleActions();

            roleActions.createAdmin();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Initialize menu database
            Database.SetInitializer(new ProductDatabaseInitializer());

            RoleActions roleActions = new RoleActions();
            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the book database.
            Database.SetInitializer(new BookDatabaseInitializer());
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #17
0
        void Application_Start(object sender, EventArgs e)
        {
            var config = GlobalConfiguration.Configuration;

            config.EnableCors();
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //// Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #18
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            string path = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\LocalDB\"));

            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            RoleActions roleHelper = new RoleActions();

            roleHelper.AddRoles();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Código que é executado na inicialização do aplicativo
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Cria regra customizada e usuário
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #21
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Initialize the product database.
            Database.SetInitializer(new DbInitializer());
            //create custom role and user
            RoleActions roleActioons = new RoleActions();

            roleActioons.AddUserAndRole();
            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer(new FileDatabaseInitializer());

            // Create the administrator role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.CreateAdmin();
        }
Exemple #23
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Database.SetInitializer(new ArticleDatabaseInitializer());

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole("Admin23", "*****@*****.**", "Pa$$word1", "roleAdmin");
            roleActions.AddUserAndRole("Editor23", "*****@*****.**", "Pa$$word1", "roleEditor");
            roleActions.AddUserAndRole("User23", "*****@*****.**", "Pa$$word1", "roleRegistered");
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #25
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());
            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;//
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the administrator role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.createAdmin();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new CatalogObjectInitializer());

            RoleActions ra = new RoleActions();

            ra.AddUserAndRole();

            RouteActions rta = new Logic.RouteActions();

            rta.RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #28
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //注册通信相关的初始化项目,准备工作
            CommStart.CommConfig();


            //创建管理员角色和用户
            RoleActions roleActions = new RoleActions();

            roleActions.createRole();
            //设备类型初始化
            DevTypeIni devTypeIni = new DevTypeIni();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //DATABASE INITIALIZER
            Database.SetInitializer(new AppDatabaseInitializer());


            // Create the administrator role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.createAdmin();
            roleActions.createMember("*****@*****.**", "123456");
        }
Exemple #30
0
        internal async Task <int> WaitAsynchronouslyDel(AspNetUser usname)
        {
            int ret = 0;

            {
                RoleActions roleActions = new RoleActions();
                if (roleActions.AdminName != usname.UserName)
                {
                    var r = await roleActions.delPrsn(usname);

                    string del_name = usname.UserName;
                    await db.SaveChangesAsync();
                }
            }
            return(ret);
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            //власний користувач та роль
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            //добавляєм шляхи
            RouteActions.RegisterCustomRoutes(RouteTable.Routes);
        }