private void loadGroups()
 {
     try
     {
         //groupName.Visible = true;
         //cblGroupName.Visible = true;
         btnSaveChanges.Visible   = true;
         btnCancelChanges.Visible = true;
         //Utils.GetLookUpData<CheckBoxList>(ref cblGroupName, LookUps.Groups, true);
         int       roleid    = Conversion.ParseInt(ddlRole.SelectedValue);
         int       subroleid = Conversion.ParseInt(ddlSubRole.SelectedValue);
         DataTable dt        = RoleManagement.GetRoleSubroleNGroupByIds(roleid, subroleid);
         if (dt != null && dt.Rows.Count > 0)
         {
             foreach (ListItem i in cblGroupName.Items)
             {
                 for (int j = 0; j < dt.Rows.Count; j++)
                 {
                     string groupid = dt.Rows[j]["intGroupID"].ToString();
                     if (i.Value == groupid)
                     {
                         i.Selected = true;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         new SqlLog().InsertSqlLog(0, "GroupPermission.aspx.loadGroups", ex);
     }
 }
Пример #2
0
        public void TestCreateUserRoleAssociation()
        {
            string[]      arr = new string[] { "28", "32" };
            ReturnMessage msg = RoleManagement.CreateUserRoleAssociation("ccc", arr);

            Assert.IsTrue(msg.Succeed);
        }
Пример #3
0
        public ActionResult Configuration(FormCollection frmCollection)
        {
            var createdBy  = Convert.ToInt64(CookieHelper.GetCookie(CookieName.UserMasterId));
            var userRoleId = RoleManagement.ConfigureRoleTransaction(frmCollection, createdBy);

            //Create Current Menu
            Session.Remove("Menu");

            //START | Bind A New Menu HERE | Add | Suchit Khunt | 30052016
            var roleId = Convert.ToInt64(CookieHelper.GetCookie(CookieName.RoleMasterId));

            //If We Found owner Then We Return ZERO.. Coz If Role ID is ZERO then it returns every Links
            if (roleId == (int)EnumList.Roles.Owner)
            {
                roleId = 0;
            }

            var menu = RoleManagement.GetMenu(roleId);

            Session["Menu"] = menu;

            //END | Bind A New Menu HERE | Add | Suchit Khunt | 30052016

            //return RedirectToAction("ConfigureRole");
            TempData["Success"] = "Configuration updated successfully";

            return(RedirectToAction("Configuration", "Role", new { id = userRoleId }));
        }
Пример #4
0
 public UserController(WorkFlowDbContext context)
 {
     converter = new Converter();
     um        = new UserManagement(context);
     rm        = new RoleManagement(context);
     es        = new EmailSendingManagement();
     pm        = new ProjectManagement(context);
 }
Пример #5
0
 // GET: Admins
 public AdminsController()
 {
     rolesManager = new RoleManager <IdentityRole>
                        (new RoleStore <IdentityRole>(db));
     usersManager = new UserManager <ApplicationUser>
                        (new UserStore <ApplicationUser>(db));
     manager = new RoleManagement(db);
 }
Пример #6
0
 public TestController()
 {
     _audit  = new AuditManagement();
     _user   = new UserManagement();
     _menu   = new MenuManagement();
     _role   = new RoleManagement();
     _client = new ClientManagement();
     _brand  = new BrandManagement();
 }
Пример #7
0
        public ActionResult List()
        {
            //We dont need any changes for Owner so we append where condition for that.
            var roleMasterId = Convert.ToInt64(CookieHelper.GetCookie(CookieName.RoleMasterId));

            var roles = RoleManagement.GetRoleList().Where(s => s.RoleMasterId != roleMasterId).ToList();

            return(View(roles));
        }
 public DolphinController()
 {
     _audit    = new AuditManagement();
     _user     = new UserManagement();
     _menu     = new MenuManagement();
     _role     = new RoleManagement();
     _client   = new ClientManagement();
     _brand    = new BrandManagement();
     _terminal = new TerminalManagement();
     _incident = new IncidentManagement();
 }
    private void loadsecuritycode()
    {
        // updating token
        try
        {
            int         roleId      = Convert.ToInt32(ddlRole.SelectedValue.ToString());
            AccessToken token       = new AccessToken();
            string      accessToken = AccessToken.ReturnEmptyToken();
            //accessToken = ReadPermissions(accessToken, token);

            // loading existing token
            int        roleid    = Conversion.ParseInt(ddlRole.SelectedValue);
            int        subroleid = Conversion.ParseInt(ddlSubRole.SelectedValue);
            DataTable  dt        = RoleManagement.GetRoleSubroleNGroupByIds(roleid, subroleid);
            List <int> groupids  = new List <int>();
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    string groupid = dt.Rows[j]["intGroupID"].ToString();
                    groupids.Add(Convert.ToInt32(groupid));
                }
                System.Data.DataTable resourceTopics = GroupPages.GetAllResources();
                for (int i = 0; i < resourceTopics.Rows.Count; i++)
                {
                    DataRow row        = resourceTopics.Rows[i];
                    int     resourceid = Convert.ToInt32(row["intResourceId"].ToString());
                    //foreach (ResourceType item in Enum.GetValues(typeof(ResourceType)))
                    //{
                    List <string> securityTokens = new List <string>();
                    foreach (int gid in groupids)
                    {
                        securityTokens.Add(RoleManagement.GetSecurityToken(Convert.ToInt32(gid)));
                    }
                    canView = canAdd = canUpdate = canDelete = false;
                    foreach (string st in securityTokens)
                    {
                        PermissionManagement.GetPermissionOnlyFalsed(resourceid, ref canView, ref canAdd, ref canUpdate, ref canDelete, st);
                    }
                    accessToken = ReadDetailPermissions(resourceid, canView, canAdd, canUpdate, canDelete, accessToken, token);
                    //}
                }
            }
            // generating new token
            RoleManagement.UpdateSecurityTokenbyRoleId(subroleid, accessToken);
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "GroupPermission.aspx.loadsecuritycode", ex);
        }
    }
Пример #10
0
        public void GetPermission(ResourceType resourceType, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete)
        {
            UserInfo user = UserInfo.GetCurrentUserInfo();


            HttpCookie cookie        = HttpContext.Current.Request.Cookies.Get("securityToken");
            string     securityToken = string.Empty;

            if (cookie == null || string.IsNullOrEmpty(cookie.Value))
            {
                //string[] GroupsArray =  user.UserGroupsCommaSeprated.Split(',');
                //int groupid = Convert.ToInt32(Convert.ToString(GroupsArray[0]));

                securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId);
                //StringBuilder sb = new StringBuilder(250);
                //sb.Append(user.RoleId);
                //sb.Append("|");
                //sb.Append(user.MemberId);
                //sb.Append("|");
                //sb.Append(securityToken);
                HttpCookie securityCookie = new HttpCookie("securityToken");
                //Decoder d= Encoding.UTF8.GetDecoder();

                ///securityCookie.Value = Encryption.Encrypt(securityToken);
                //////securityCookie.Value = Server.UrlEncode(sb.ToString());
                securityCookie.Value = Server.UrlEncode(securityToken);

                HttpContext.Current.Response.Cookies.Add(securityCookie);
            }
            else
            {
                //securityToken = Encryption.Decrypt(cookie.Value);
                securityToken = Server.UrlDecode(cookie.Value);
                //string cookieSecurityToken = string.Empty;
                //cookieSecurityToken = Server.UrlDecode(cookie.Value);
                //string[] cookieValue = GetInfoFromCookie(cookieSecurityToken);
                //if (cookieValue != null)
                //{

                //    if (user.MemberId == Convert.ToInt32(cookieValue[0]))
                //    { }
                //    if (user.RoleId == Convert.ToInt32(cookieValue[1]))
                //    { }
                //    securityToken = cookieValue[2].ToString();
                //}
            }



            PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken);
        }
Пример #11
0
        public void GetPermission(ResourceType resourceType, int memberId, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete)
        {
            UserInfo user = UserInfo.UserTopRole(memberId);

            HttpCookie cookie        = HttpContext.Current.Request.Cookies.Get("securityToken");
            string     securityToken = string.Empty;

            if (user != null)
            {
                securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId);

                PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken);
            }
        }
Пример #12
0
        public ActionResult Configuration(int id = 0)
        {
            if (id == 0)
            {
                return(HttpNotFound());
            }

            var menuVMs = RoleManagement.GetPagesForSelectedRole(id).ToList();

            ViewBag.RoleID   = id;
            ViewBag.RoleName = RoleManagement.GetRoleNameById(id);

            return(View(menuVMs));
        }
Пример #13
0
        private void CreateRoleFeatures(string feature, bool IsAllowed, string RoleID, string UserID)
        {
            RoleManagement rolemgtentity = new RoleManagement();

            rolemgtentity.RoleManagementID = Guid.NewGuid().ToString();
            rolemgtentity.Active           = true;
            rolemgtentity.RoleFeatureName  = feature;
            rolemgtentity.RoleID           = RoleID;
            rolemgtentity.IsAllowed        = IsAllowed;
            rolemgtentity.CreatedUserID    = UserID;
            rolemgtentity.CratedDate       = DateTime.Now;
            mBMSEntities.RoleManagements.Add(rolemgtentity);
            mBMSEntities.SaveChanges();
        }
Пример #14
0
        public DiscordBot(AppSettings appSettings)
        {
            _discordClient = new DiscordClient(new DiscordConfiguration {
                Token                 = appSettings.DiscordBotToken,
                TokenType             = TokenType.Bot,
                LogLevel              = LogLevel.Debug,
                UseInternalLogHandler = true
            });

            _userManager    = new UserManagement(appSettings.MSSQLConnectionString);
            _guildManager   = new GuildManagement(appSettings.MSSQLConnectionString);
            _roleManager    = new RoleManagement(appSettings.MSSQLConnectionString);
            _channelManager = new ChannelManagement(appSettings.MSSQLConnectionString);
            //_presenceManager = new PresenceManagement(appSettings.MSSQLConnectionString);
            //_linkManager = new LinkManagement(appSettings.MSSQLConnectionString);

            _serverManager = new ServerManager(_userManager, _guildManager, _roleManager, _channelManager);

            _messageHandler = new MessageHandler(appSettings.MSSQLConnectionString);
            //var dependency = new DependencyCollectionBuilder();
            //dependency.AddInstance(_userManager);

            //var commands = _discordClient.UseCommandsNext(new CommandsNextConfiguration {
            //    StringPrefix = "+",
            //    Dependencies = dependency.Build()
            //});

            //commands.RegisterCommands<LinkCommand>();
            //commands.RegisterCommands<RegisterCommand>();


            _discordClient.MessageCreated  += _discordClient_MessageCreated;
            _discordClient.MessageUpdated  += _discordClient_MessageUpdated;
            _discordClient.PresenceUpdated += _discordClient_PresenceUpdated;
            //_discordClient.UserUpdated += _discordClient_UserUpdated;
            _discordClient.Ready += _discordClient_Ready;
            //_discordClient.Heartbeated += _discordClient_Heartbeated;
            //_discordClient.GuildAvailable += _discordClient_GuildAvailable;
            //_discordClient.GuildMemberAdded += _discordClient_GuildMemberAdded;
            // triggers on nick changes
            //_discordClient.GuildMemberUpdated += _discordClient_GuildMemberUpdated;

            _taskRunner.RegisterTask(new UserTask(_discordClient, _serverManager), new TimeSpan(0, 0, 5));

            Task.Run(async() => {
                await Connect();
            });
        }
Пример #15
0
    protected void btnAdminLogin_Click(object sender, EventArgs e)
    {
        // Member_login(txtusername.Text.Trim(), txtpassword.Text.Trim());
        Member_login(Utils.CleanHTML(txtusername.Text.Trim()), txtpassword.Text.Trim());
        //HttpCookie cookie1 = new HttpCookie("AdminRememberUserCookie", );
        //cookie1.Expires = DateTime.Now.AddDays(1);
        //HttpContext.Current.Response.Cookies.Add(cookie1);

        string loginTime = "";

        if (chkBoxRemember.Checked)
        {
            loginTime = System.Configuration.ConfigurationManager.AppSettings["LoginTimeRemember"];
            UserInfo   user          = UserInfo.GetCurrentUserInfo();
            HttpCookie cookie        = HttpContext.Current.Request.Cookies.Get("securityToken");
            string     securityToken = string.Empty;
            securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId);
            HttpCookie securityCookie = new HttpCookie("securityToken");
            securityCookie.Value   = Server.UrlEncode(securityToken);
            securityCookie.Expires = DateTime.Now.AddMinutes(Convert.ToInt16(loginTime));
            HttpContext.Current.Response.Cookies.Add(securityCookie);
            cookie         = new HttpCookie("AdminRememberUserCookieTime");
            cookie.Value   = DateTime.Now.AddMinutes(Convert.ToInt16(loginTime)).ToString();
            cookie.Expires = DateTime.Now.AddMinutes(Convert.ToInt16(loginTime));
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
        else
        {
            //      new SqlLog().InsertSqlLog(0, "before getting key of logintTime from web.conf", new Exception());
            loginTime = System.Configuration.ConfigurationManager.AppSettings["LoginTime"];
            //       new SqlLog().InsertSqlLog(0, "after  getting key of logintTime from web.conf", new Exception());
            UserInfo   user          = UserInfo.GetCurrentUserInfo();
            HttpCookie cookie        = HttpContext.Current.Request.Cookies.Get("securityToken");
            string     securityToken = string.Empty;
            securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId);
            HttpCookie securityCookie = new HttpCookie("securityToken");
            securityCookie.Value = Server.UrlEncode(securityToken);
            //     new SqlLog().InsertSqlLog(0, "after adding security token", new Exception());
            securityCookie.Expires = DateTime.Now.AddMinutes(Convert.ToInt16(loginTime));
            HttpContext.Current.Response.Cookies.Add(securityCookie);
            cookie         = new HttpCookie("AdminRememberUserCookieTime");
            cookie.Value   = DateTime.Now.AddMinutes(Convert.ToInt16(loginTime)).ToString();
            cookie.Expires = DateTime.Now.AddMinutes(Convert.ToInt16(loginTime));
            HttpContext.Current.Response.Cookies.Add(cookie);
            //     new SqlLog().InsertSqlLog(0, "after adding AdminRememberUserCookieTime", new Exception());
        }
        // Response.Redirect("/Dashboard/adminDashboard.aspx",true);
    }
Пример #16
0
    protected void ddlGroupName_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            lblInfo.Text = "";
            if (ddlGroupName.SelectedIndex != 0)
            {
                EnableControls(true);
                chkAdmin.Enabled = true;
                chkAdmin.Checked = false;
                SetAllPermissionsOff();
                int    roleId        = Convert.ToInt32(ddlGroupName.SelectedValue.ToString());
                string securityToken = RoleManagement.GetSecurityToken(roleId);

                AccessToken token = new AccessToken();
                if (token.AdminToken(64, token.EmptyString()).Equals(securityToken))
                {
                    SetAllPermissionsOn();
                    EnableControls(false);
                    chkAdmin.Checked = true;
                }
                else if (!string.IsNullOrEmpty(securityToken))
                {
                    ReadFromAccess(securityToken, token);
                    chkAdmin.Checked = false;
                }
                else
                {
                    SetAllPermissionsOff();
                    chkAdmin.Checked = false;
                    EnableControls(true);
                }
            }
            else
            {
                SetAllPermissionsOff();
                chkAdmin.Enabled = false;
                EnableControls(false);
            }
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "PagePermission.aspx ddlGroupName_SelectedIndexChanged", ex);
        }
    }
Пример #17
0
        public void GetPermission(ResourceType resourceType, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete, string groupid)
        {
            HttpCookie cookie        = HttpContext.Current.Request.Cookies.Get("securityToken");
            string     securityToken = string.Empty;

            if (cookie == null || string.IsNullOrEmpty(cookie.Value))
            {
                securityToken = RoleManagement.GetSecurityToken(Convert.ToInt32(groupid));
                HttpCookie securityCookie = new HttpCookie("securityToken");
                securityCookie.Value = Server.UrlEncode(securityToken);
                HttpContext.Current.Response.Cookies.Add(securityCookie);
            }
            else
            {
                securityToken = Server.UrlDecode(cookie.Value);
            }
            PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken);
        }
Пример #18
0
        public void GetPermission(ResourceType resourceType, int memberId, ref bool canView, ref bool canAdd, ref bool canUpdate, ref bool canDelete)
        {
            UserInfo user = UserInfo.UserTopRole(memberId);

            HttpCookie cookie        = HttpContext.Current.Request.Cookies.Get("securityToken");
            string     securityToken = string.Empty;

            if (user != null)
            {
                securityToken = RoleManagement.GetSecurityTokenByRoleId(user.RoleId);
                //DataSet ds= RoleManagement.GetSecurityTokenByGroupIds(user.UserGroupsCommaSeprated);
                //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                //{
                //    foreach (DataRow row in ds.Tables[0].Rows)
                //    {
                //securityToken = Conversion.ParseDBNullString(row["vchSecurityCode"]);
                PermissionManagement.GetPermission(resourceType, ref canView, ref canAdd, ref canUpdate, ref canDelete, securityToken);
                //    }
                //}
            }
        }
 public static Cryptography.ECC.ECPoint[] getOracleNodes()
 {
     return(RoleManagement.GetDesignatedByRole(Role.Oracle, 0));
 }
Пример #20
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            string            vIPadd = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();
            string            xurl;
            UserBusinessLogic UserBL   = new UserBusinessLogic();
            RoleManagement    userRole = new RoleManagement();

            if (ModelState.IsValid)
            {
                string  pwdX       = Crypto.SHA1(model.Password);
                Boolean IsValid    = UserBL.isValidUser(model.UserName, pwdX);
                Boolean isDisabled = UserBL.isAcctDisabled(model.UserName, model.Password);
                if (isDisabled == true)
                {
                    ModelState.AddModelError("", "Your account is currently disabled");

                    IList <UserLogFail> UserLogFails = new List <UserLogFail>();
                    UserLogFail         Ulog         = new UserLogFail();
                    Ulog.EmailAdd  = model.UserName;
                    Ulog.ErrorMsg  = "Your account is currently disabled";
                    Ulog.LogDate   = DateTime.Now;
                    Ulog.SessionId = Session.SessionID.ToString();
                    Ulog.Typ       = 0;
                    Ulog.IPadd     = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();
                    UserLogFails.Add(Ulog);
                    UserLogFailBL.InsertUserLogFail(Ulog);
                }
                else
                {
                    //int xcounter = 0;
                    //xcounter = UserLogFailBL.FailedCounter(model.UserName, Session.SessionID.ToString());
                    //if (xcounter >= 10 || xcounter <50 )
                    //{
                    //System.Threading.Thread.Sleep(5000);
                    //}


                    if (IsValid == true)
                    {
                        string username = NewMethod(model);
                        int    userid   = Convert.ToInt32(UserBL.Users.SingleOrDefault(x => x.EmailAdd == username).ID.ToString());
                        Session["user"]      = model.UserName;
                        Session["userID"]    = UserBL.Users.SingleOrDefault(x => x.EmailAdd == username).ID.ToString();
                        Session["rowfilter"] = UserBL.Users.SingleOrDefault(x => x.EmailAdd == username).iNumRows.ToString();
                        Session["fullname"]  = UserBL.Users.SingleOrDefault(x => x.EmailAdd == username).FirstName.ToString() + " " + UserBL.Users.SingleOrDefault(x => x.EmailAdd == username).SurName.ToString();
                        Session["isAdmin"]   = userRole.UserRoleAccess.Any(x => x.UserID == userid) ? "True" : "False";

                        IList <UserLog> UserLogs = new List <UserLog>();
                        UserLog         Ulog     = new UserLog();
                        Ulog.EmailAdd = model.UserName;
                        Ulog.LogDate  = DateTime.Now;
                        Ulog.Typ      = 0;
                        Ulog.IPadd    = vIPadd;
                        UserLogs.Add(Ulog);
                        UserLogBL.InsertUserLog(Ulog);
                        UserLogFailBL.ClearedLogFail(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString());


                        //  Session["cutoff"] = UserBL.ActiveCutOff(model.UserName);
                        xurl = "dboard";
                        return(RedirectToLocal(xurl));
                    }
                    else
                    {
                        IList <UserLogFail> UserLogFails = new List <UserLogFail>();
                        UserLogFail         Ulog         = new UserLogFail();
                        Ulog.EmailAdd  = model.UserName;
                        Ulog.ErrorMsg  = "Invalid username or password.";
                        Ulog.LogDate   = DateTime.Now;
                        Ulog.Typ       = 0;
                        Ulog.SessionId = Session.SessionID.ToString();
                        Ulog.IPadd     = vIPadd;
                        UserLogFails.Add(Ulog);
                        UserLogFailBL.InsertUserLogFail(Ulog);
                        Session["user"] = model.UserName;

                        vIPadd = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();

                        DateTime DueDate = DateTime.Now;

                        ViewBag.duetime = DateTime.Now.AddSeconds(1);

                        ModelState.AddModelError("", "Invalid username or password.");
                    }
                }
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Пример #21
0
 public RoleController(WorkFlowDbContext context)
 {
     rm        = new RoleManagement(context);
     converter = new Converter();
 }
Пример #22
0
    protected void btnAddResources_Click(object sender, EventArgs e)
    {
        try
        {
            if (ddlGroupName.SelectedIndex != 0)
            {
                //GetPermission(TireTraxLib.ResourceType.PagePermissions, ref canView, ref canAdd, ref canUpdate, ref canDelete,ddlGroupName.SelectedValue);
                //if (!canUpdate)
                //{
                //    lblInfo.Text = "Sorry, you dont have right to change the premission";
                //}
                //else
                //{
                int         groupId     = Convert.ToInt32(ddlGroupName.SelectedValue.ToString());
                AccessToken token       = new AccessToken();
                string      accessToken = AccessToken.ReturnEmptyToken();
                if (chkAdmin.Checked)
                {
                    accessToken = token.AdminToken(64, accessToken);
                }
                else
                {
                    accessToken = ReadPermissions(accessToken, token);
                }

                RoleManagement.UpdateSecurityToken(groupId, accessToken);

                //it is used to update the Security token for Roles
                DataTable dt = RoleManagement.getDistinctRolesByGroupId(groupId);
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int TempRoleId    = Conversion.ParseInt(dt.Rows[i]["RoleId"]);
                        int TempSubRoleId = Conversion.ParseInt(dt.Rows[i]["SubRoleId"]);
                        regenerateSecurityTokens(TempRoleId, TempSubRoleId);
                    }
                }
                lblInfo.ForeColor = System.Drawing.Color.Green;
                lblInfo.Text      = "Permission is Successfully Added";

                //Update Cookies
                // UserInfo user = UserInfo.GetCurrentUserInfo();
                Response.Cookies["securityToken"].Expires = DateTime.Now.AddMinutes(-1);
                string securityToken = string.Empty;
                securityToken = RoleManagement.GetSecurityTokenByRoleId(groupId);
                //HttpCookie securityCookie = new HttpCookie("securityToken");
                //Decoder d= Encoding.UTF8.GetDecoder();

                //securityCookie.Value = Server.UrlEncode(securityToken);
                //HttpContext.Current.Response.Cookies.Add(securityCookie);
                // }
            }
            else
            {
                lblInfo.ForeColor = System.Drawing.Color.Red;
                lblInfo.Text      = "Please Select the Group";
            }
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "PagePermission.aspx btnAddResources_Click", ex);
        }
    }
Пример #23
0
        public void TestCreateRole()
        {
            ReturnMessage msg = RoleManagement.CreateRole("test", "test");

            Assert.IsTrue(msg.Succeed);
        }
Пример #24
0
        public void TestGetUserRoleAssociation()
        {
            ReturnMessage msg = RoleManagement.GetUserRoleAssociation("2", "ccc");

            Assert.IsTrue(msg.Succeed);
        }
Пример #25
0
        public void TestGetUser()
        {
            ReturnMessage msg = RoleManagement.GetUser("a");

            Assert.IsTrue(msg.Succeed);
        }
Пример #26
0
        public void TestGetFullRoles()
        {
            ReturnMessage msg = RoleManagement.GetFullRoles();

            Assert.IsTrue(msg.Succeed);
        }
Пример #27
0
 public AccountController(WorkFlowDbContext context)
 {
     um = new UserManagement(context);
     rm = new RoleManagement(context);
 }
Пример #28
0
 public RoleManagementTest()
 {
     RoleManagement.Initialize("OPFN30\\Administrator", "SwqaMe$1", "http://localhost");
 }
 public Configuration()
 {
     dbContext                  = new ApplicationDbContext();
     roleManagement             = new RoleManagement(dbContext);
     AutomaticMigrationsEnabled = false;
 }
Пример #30
0
        public ActionResult Login(AccountVm data)
        {
            try
            {
                using (_entities)
                {
                    // Ensure we have a valid viewModel to work with
                    if (!ModelState.IsValid)
                    {
                        return(View(data));
                    }

                    //Initialise object of usermaster table
                    var userMaster = _entities.UserMasters.FirstOrDefault(s => s.Email == data.EmailLogin.Trim());

                    //Check that details is not null
                    if (userMaster != null)
                    {
                        var oldHashValue = userMaster.Hash;
                        var salt         = userMaster.Salt;

                        var isLogin = Utilities.CompareHashValue(data.PasswordLogin.Trim(), userMaster.Email,
                                                                 oldHashValue, salt);

                        if (isLogin)
                        {
                            //Login Success
                            //For Set Authentication in Cookie (Remeber ME Option)
                            SignInRemember(data.Email, data.IsRemember);

                            //Set A Unique ID in session
                            CookieHelper.SetCookie(CookieName.UserMasterId, userMaster.UserMasterId.ToString(), 36);
                            CookieHelper.SetCookie(CookieName.Name, userMaster.Name, 36);
                            CookieHelper.SetCookie(CookieName.RoleMasterId, userMaster.RoleMasterId.ToString(), 36);

                            string profileImage;
                            if (!string.IsNullOrWhiteSpace(userMaster.Profile))
                            {
                                profileImage = BasicProperty.ProfilePath + userMaster.Profile;
                            }
                            else
                            {
                                profileImage = "/Content/img/userIcon.jpg";
                            }

                            CookieHelper.SetCookie(CookieName.ProfileImage, profileImage, 36);

                            //Set Menu in session
                            var menu = RoleManagement.GetMenu(userMaster.RoleMasterId);
                            Session["Menu"] = menu;

                            TempData["Success"] = "Welcome to DevTracker";

                            // If we got this far, something failed, redisplay form
                            // return RedirectToAction("Index", "Dashboard");
                            return(RedirectToLocal(data.ReturnUrl));
                        }

                        TempData["Error"] = "Access Denied! You enter wrong credentials!";
                    }
                    else
                    {
                        TempData["Error"] = "Access Denied! You enter wrong credentials!";
                    }
                }

                return(RedirectToAction("Login"));
            }
            catch (Exception e)
            {
                TempData["Error"] = e.Message;
                throw;
            }
        }