예제 #1
0
        public async Task <IOperationResult <ISet <Meeting> > > GetMeetingsHistory(int userId)
        {
            bool userExists = await _userRepository.Exists(u => u.Id == userId && u.IsActive && u.IsEmailValidated);

            if (!userExists)
            {
                return(BasicOperationResult <ISet <Meeting> > .Fail("El usuario indicado no fue encontrado, verifique e intente nuevamente."));
            }

            ISet <RoleTypes> roles = await _userRepository.GetRolesForUser(userId);

            RoleTypes role = roles.FirstOrDefault();

            IEnumerable <Meeting> meetings = await _getMeetingsByRole[role](userId);

            MeetingStatus[] statusesToFilterBy =
            {
                MeetingStatus.Complete,
                MeetingStatus.Cancelled,
                MeetingStatus.InProgress,
                MeetingStatus.Rejected,
                MeetingStatus.Accepted
            };

            HashSet <Meeting> filteredMeetings = meetings.Where(m => statusesToFilterBy.Contains(m.Status))
                                                 .OrderBy(m => m.StartDateTime)
                                                 .ThenBy(m => m.RealStartedDateTime)
                                                 .ToHashSet();

            return(BasicOperationResult <ISet <Meeting> > .Ok(filteredMeetings));
        }
예제 #2
0
        public Result <LoginInfo> Login(string login, string pass, RoleTypes roleType)
        {
            SessionInfo sessionInfo;
            var         logonResult = LogonManager.Login(login, pass, roleType, out sessionInfo);

            switch (logonResult)
            {
            case LogonResult.Ok:
                return(new Result <LoginInfo>(sessionInfo.GetLoginInfo()));

            case LogonResult.AlreadyLogined:
                LogonManager.Logout(sessionInfo.Guid);
                return(Login(login, pass, roleType));

            case LogonResult.WrongLoginOrPass:
                return(new Result <LoginInfo>(Result.LoginOrPassIsWrong()));

            case LogonResult.WrongRole:
                return(new Result <LoginInfo>(Result.AccsessDeny()));

            default:
                return(new Result <LoginInfo>(false)
                {
                    Message = "Ошибка: Не известный результат идентификации"
                });
            }
        }
예제 #3
0
        public MarketingOrdersForm(LightStartForm tLightStartForm)
        {
            InitializeComponent();
            LightStartForm = tLightStartForm;


            this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;

            Initialize();

            RolePermissionsDataTable = OrdersManager.GetPermissions(Security.CurrentUserID, this.Name);

            if (!PermissionGranted(iMarketing) && !PermissionGranted(iAdmin))
            {
                tableLayoutPanel1.Height = this.Height - NavigatePanel.Height - 10;
                ToolsPanel.Visible       = false;
            }
            if (PermissionGranted(iMarketing))
            {
                RoleType = RoleTypes.Marketing;
            }
            if (PermissionGranted(iAdmin))
            {
                RoleType = RoleTypes.Admin;
            }

            while (!SplashForm.bCreated)
            {
                ;
            }
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the RoleAssignmentResourceFormatInner
 /// class.
 /// </summary>
 /// <param name="role">Type of roles. Possible values include: 'Admin',
 /// 'Reader', 'ManageAdmin', 'ManageReader', 'DataAdmin',
 /// 'DataReader'</param>
 /// <param name="principals">The principals being assigned to.</param>
 /// <param name="id">Resource ID.</param>
 /// <param name="name">Resource name.</param>
 /// <param name="type">Resource type.</param>
 /// <param name="tenantId">The hub name.</param>
 /// <param name="assignmentName">The name of the metadata
 /// object.</param>
 /// <param name="displayName">Localized display names for the
 /// metadata.</param>
 /// <param name="description">Localized description for the
 /// metadata.</param>
 /// <param name="provisioningState">Provisioning state. Possible values
 /// include: 'Provisioning', 'Succeeded', 'Expiring', 'Deleting',
 /// 'HumanIntervention', 'Failed'</param>
 /// <param name="profiles">Profiles set for the assignment.</param>
 /// <param name="interactions">Interactions set for the
 /// assignment.</param>
 /// <param name="links">Links set for the assignment.</param>
 /// <param name="kpis">Kpis set for the assignment.</param>
 /// <param name="sasPolicies">Sas Policies set for the
 /// assignment.</param>
 /// <param name="connectors">Connectors set for the assignment.</param>
 /// <param name="views">Views set for the assignment.</param>
 /// <param name="relationshipLinks">The Role assignments set for the
 /// relationship links.</param>
 /// <param name="relationships">The Role assignments set for the
 /// relationships.</param>
 /// <param name="widgetTypes">Widget types set for the
 /// assignment.</param>
 /// <param name="roleAssignments">The Role assignments set for the
 /// assignment.</param>
 /// <param name="conflationPolicies">Widget types set for the
 /// assignment.</param>
 /// <param name="segments">The Role assignments set for the
 /// assignment.</param>
 public RoleAssignmentResourceFormatInner(RoleTypes role, IList <AssignmentPrincipal> principals, string id = default(string), string name = default(string), string type = default(string), string tenantId = default(string), string assignmentName = default(string), IDictionary <string, string> displayName = default(IDictionary <string, string>), IDictionary <string, string> description = default(IDictionary <string, string>), string provisioningState = default(string), ResourceSetDescription profiles = default(ResourceSetDescription), ResourceSetDescription interactions = default(ResourceSetDescription), ResourceSetDescription links = default(ResourceSetDescription), ResourceSetDescription kpis = default(ResourceSetDescription), ResourceSetDescription sasPolicies = default(ResourceSetDescription), ResourceSetDescription connectors = default(ResourceSetDescription), ResourceSetDescription views = default(ResourceSetDescription), ResourceSetDescription relationshipLinks = default(ResourceSetDescription), ResourceSetDescription relationships = default(ResourceSetDescription), ResourceSetDescription widgetTypes = default(ResourceSetDescription), ResourceSetDescription roleAssignments = default(ResourceSetDescription), ResourceSetDescription conflationPolicies = default(ResourceSetDescription), ResourceSetDescription segments = default(ResourceSetDescription))
     : base(id, name, type)
 {
     TenantId          = tenantId;
     AssignmentName    = assignmentName;
     DisplayName       = displayName;
     Description       = description;
     ProvisioningState = provisioningState;
     Role               = role;
     Principals         = principals;
     Profiles           = profiles;
     Interactions       = interactions;
     Links              = links;
     Kpis               = kpis;
     SasPolicies        = sasPolicies;
     Connectors         = connectors;
     Views              = views;
     RelationshipLinks  = relationshipLinks;
     Relationships      = relationships;
     WidgetTypes        = widgetTypes;
     RoleAssignments    = roleAssignments;
     ConflationPolicies = conflationPolicies;
     Segments           = segments;
     CustomInit();
 }
예제 #5
0
        public LoginResponse Login(LoginRequest request)
        {
            var userFromRepo = GetUser(request);

            if (userFromRepo == null)
            {
                LoginResponse response = new LoginResponse();
                response.isSuccess    = false;
                response.ErrorMessage = "Hatalı kullanıcı adı/şifre";
                return(response);
            }
            else
            {
                var tokenHandler = new JwtSecurityTokenHandler();
                var key          = Encoding.ASCII.GetBytes(_configuration.GetSection("JWTSettings:SecretKey").Value);

                var userRoles                   = GetUserRoles(request);
                List <RoleTypes> typeList       = new List <RoleTypes>();
                ClaimsIdentity   claimsIdentity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie);


                claimsIdentity.AddClaim(new Claim(ClaimTypes.Name, userFromRepo.UserName));
                claimsIdentity.AddClaim(new Claim(ClaimTypes.Sid, userFromRepo.UserId.ToString()));

                foreach (var role in userRoles.RoleTypeList)
                {
                    claimsIdentity.AddClaim(new Claim(ClaimTypes.Role, role.RoleName));

                    RoleTypes type = new RoleTypes();
                    type.UserId   = role.UserId;
                    type.UserName = role.UserName;
                    type.RoleName = role.RoleName;
                    typeList.Add(type);
                }
                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Subject            = claimsIdentity,
                    Issuer             = _configuration.GetSection("JWTSettings:Issuer").Value,
                    Expires            = DateTime.Now.AddDays(int.Parse(_configuration.GetSection("JWTSettings:ExpireDays").Value)),
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha512Signature)
                };


                //IPrincipal user = new ClaimsPrincipal(claimsIdentity);

                var token       = tokenHandler.CreateToken(tokenDescriptor);
                var tokenString = tokenHandler.WriteToken(token);

                string fullName = userFromRepo.UserName;
                int    userId   = userFromRepo.UserId;

                LoginResponse response = new LoginResponse();
                response.isSuccess = true;
                response.UserName  = fullName;
                response.UserId    = userId;
                response.Token     = tokenString;
                response.UserRoles = typeList;
                return(response);
            }
        }
예제 #6
0
        public static List <Course_Schedule> GetSchedulesOf(User user, RoleTypes roleType)
        {
            using (KeunhongInstituteDBEntities dbContext = new KeunhongInstituteDBEntities())
            {
                //Check role type
                if (roleType == RoleTypes.Student)
                {
                    //Find all student course object with the user's id
                    var selections = dbContext.Student_Course.Where(sc => sc.User_ID.Equals(user.User_ID) && sc.IsActive);

                    //Convert student_course to course_schedule
                    List <Course_Schedule> courseSchedules = new List <Course_Schedule>();
                    foreach (Student_Course sc in selections)
                    {
                        Course_Schedule cs = sc.GetSchedule();
                        if (cs != null)
                        {
                            courseSchedules.Add(cs);
                        }
                    }

                    //Return the list
                    return(courseSchedules);
                }
                else
                {
                    //Return all course_schedules where its teacher_id equals the given user's id.
                    var selections = dbContext.Course_Schedule.Where(s => s.Teacher_ID.Equals(user.User_ID) && s.IsActive);
                    return(selections.ToList());
                }
            }
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("RoleTypeID,RoleDesc")] RoleTypes roleTypes)
        {
            if (id != roleTypes.RoleTypeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(roleTypes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoleTypesExists(roleTypes.RoleTypeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(roleTypes));
        }
예제 #8
0
 public RoleDetailViewModel(string id, string name, string description, RoleTypes type)
 {
     Id          = id;
     Name        = name;
     Description = description;
     Type        = type;
 }
예제 #9
0
        public string SetRole(long idUser, RoleTypes roleTypes)
        {
            // Sempre apaga a permissão
            int d = DestroyWhere <User_Roles, WhereObjects>(new WhereObjects()
            {
                user_roles = new User_Roles()
                {
                    user_id = idUser
                }
            });

            // Somente admin devem estar na lista de admin
            if (roleTypes == RoleTypes.Admin)
            {
                long a = Add <User_Roles>(new User_Roles()
                {
                    user_id  = idUser,
                    RoleType = RoleTypes.Admin
                });
                return(a > 0 ? "ROLE ADMIN" : "ERRO ADMIN");
            }
            else
            {
                return(d > 0 ? "ROLE USER" : "USER");
            }
        }
예제 #10
0
 public RoleSeedModel(string name, RoleTypes type, string description, List <string> permissions)
 {
     Name        = name;
     Type        = type;
     Description = description;
     Permissions = permissions;
 }
예제 #11
0
        private XElement CreateAppInfo()
        {
            var xAppInfo = new XElement(SchemaXNames.AppInfo);

            xAppInfo.Add(RoleTypes.Select(rt => rt.ToXml()));
            xAppInfo.Add(Dependencies.OfType <Linkbase>().Select(lb => lb.CreateLinkbaseRef()));
            return(xAppInfo);
        }
예제 #12
0
            public ViewModel(string roleId, string roleName, RoleTypes roleType, TabSelected tabSelected)
            {
                RoleId   = roleId;
                RoleName = roleName;
                RoleType = roleType;

                TabSelected = tabSelected;
            }
예제 #13
0
        public RoleInfo(string _name, RoleTypes _type, Type _roleClass)
        {
            name      = _name;
            type      = _type;
            roleClass = _roleClass;

            id = IdPool++;
        }
예제 #14
0
        public Account AddRole(int accountId, RoleTypes role)
        {
            var account   = DbSet.First(a => a.Id == accountId);
            var roleToAdd = _context.Roles.First(r => r.Name == role.ToString());

            account.Roles.Add(roleToAdd);
            _context.SaveChanges();
            return(account);
        }
예제 #15
0
 public void SetParam(JSON_UnitParam json)
 {
     this.default_skill = json.dskl;
     this.jobtype       = (JobTypes)json.jt;
     this.role          = (RoleTypes)json.role;
     this.mov           = (byte)json.mov;
     this.jmp           = (byte)json.jmp;
     this.inimp         = json.inimp;
 }
예제 #16
0
파일: Roles.cs 프로젝트: Lugghawk/libeveapi
        /// <summary>
        /// Return true if the specified role is present
        /// </summary>
        /// <param name="roleType">Type of role</param>
        /// <returns>True/False</returns>
        public bool HasRole(RoleTypes roleType)
        {
            if (rolesTable.Contains(roleType))
            {
                return(true);
            }

            return(false);
        }
예제 #17
0
        public RoleTypeDto GetRoleTypeDto(RoleTypes roleTypes)
        {
            var dto = new RoleTypeDto();

            dto.Id   = roleTypes.Id;
            dto.Role = roleTypes.Role;

            return(dto);
        }
예제 #18
0
        public void TypeTest()
        {
            Assert.IsNull(Obj.Type);
            var t = RoleType.Random();

            t.UniqueId = Obj.TypeId;
            RoleTypes.Instance.AddRange(RoleTypes.Random());
            RoleTypes.Instance.Add(t);
            Assert.AreEqual(t, Obj.Type);
        }
예제 #19
0
 public Account(int id, string name, string surname, int age, string password, string email, RoleTypes roleType)
 {
     ID       = id;
     Name     = name;
     Surname  = surname;
     Age      = age;
     Password = password;
     Email    = email;
     Role     = roleType;
 }
예제 #20
0
        public async Task <IActionResult> Create([Bind("RoleTypeID,RoleDesc")] RoleTypes roleTypes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roleTypes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(roleTypes));
        }
예제 #21
0
 private void AddRoleTypes()
 {
     RoleTypes.Add(new SelectOptionViewModel(AdminResources.RoleTypeAreaNoise, "AreaNoise"));
     RoleTypes.Add(new SelectOptionViewModel(AdminResources.RoleTypeHelideck, "Helideck"));
     RoleTypes.Add(new SelectOptionViewModel(AdminResources.RoleTypeHelideck, "Helipassenger"));
     RoleTypes.Add(new SelectOptionViewModel(AdminResources.RoleTypeRegular, "Regular")
     {
         IsSelected = true
     });
     RoleTypes.Add(new SelectOptionViewModel(AdminResources.RoleTypeRotation, "Rotation"));
 }
예제 #22
0
        public static RoleDTO GetRoleDTO(RoleTypes roleType)
        {
            var role = new RoleDTO
            {
                RoleName             = roleType.ToString(),
                RoleDescription      = EnumUtil.GetEnumDesc(roleType),
                RoleDescriptionShort = roleType.ToString()
            };

            return(role);
        }
예제 #23
0
        public void Ctor_Success()
        {
            var result = new RoleTypes
            {
                Id   = 10,
                Name = "name"
            };

            Assert.Equal(10, result.Id);
            Assert.Equal("name", result.Name);
        }
예제 #24
0
        public ActionResult MoveOrder(int orderId, int newWarehouseId, int userId, RoleTypes role)
        {
            productService.MoveOrder(orderId, newWarehouseId);
            switch (role)
            {
            case RoleTypes.Supplier:
                return(RedirectToAction("OrdersList", new { userId = userId }));

            default:
                return(RedirectToAction("GetAllOrders"));
            }
        }
예제 #25
0
        private async Task <User> CreateAspUser(SchoolUser schoolUser, RoleTypes role)
        {
            var accountRegister = new FullRegisterInputModel
            {
                Pin       = schoolUser.Pin,
                FirstName = schoolUser.FirstName,
                LastName  = schoolUser.LastName,
                RoleName  = role.ToString()
            };

            return(await _accountService.Register(accountRegister));
        }
예제 #26
0
        public void SetSharedData(IPrincipal User)
        {
            var claimIdentity     = ((ClaimsIdentity)User.Identity);
            var fullName          = claimIdentity.Claims.FirstOrDefault(x => x.Type == "FullName");
            var profilePictureUrl = claimIdentity.Claims.FirstOrDefault(x => x.Type == "ProfilePictureUrl");

            UserName          = fullName == null ? "John Doe" : fullName.Value;
            ProfilePictureUrl = string.IsNullOrEmpty(profilePictureUrl.Value) ? "~/Content/images/img.jpg" : profilePictureUrl.Value;
            Id      = Convert.ToInt32(claimIdentity.Claims.FirstOrDefault(x => x.Type == "AdminId").Value);
            Role    = (RoleTypes)(Convert.ToInt32(claimIdentity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Role).Value));
            StoreId = Convert.ToInt32(claimIdentity.Claims.FirstOrDefault(x => x.Type == "StoreId").Value);
        }
예제 #27
0
        public static void Postfix(ref int __result, ref RoleTypes role)
        {
            if (role == RoleTypes.Crewmate || role == RoleTypes.Impostor)
            {
                return;
            }

            if (CustomOptionHolder.activateRoles.getBool())
            {
                __result = 0;                                             // Deactivate Vanilla Roles if the mod roles are active
            }
        }
예제 #28
0
        public static List <RoleInfo> GetRolesByType(RoleTypes type)
        {
            List <RoleInfo> roles = new List <RoleInfo>();

            foreach (RoleInfo role in RoleTypeList)
            {
                if (role.type == type)
                {
                    roles.Add(role);
                }
            }
            return(roles);
        }
예제 #29
0
        public static IProvideMetadata AddPermission(this IProvideMetadata type, RoleTypes permission)
        {
            var permissions = type.GetMetadata <List <string> >(PermissionsKey);

            if (permissions == null)
            {
                permissions = new List <string>();
                type.Metadata[PermissionsKey] = permissions;
            }

            permissions.Fill(permission.ToString());

            return(type);
        }
예제 #30
0
 public bool Deserialize(JSON_JobParam json)
 {
     if (json == null)
     {
         return(false);
     }
     this.iname              = json.iname;
     this.name               = json.name;
     this.expr               = json.expr;
     this.model              = json.mdl;
     this.ac2d               = json.ac2d;
     this.modelp             = json.mdlp;
     this.pet                = json.pet;
     this.buki               = json.buki;
     this.origin             = json.origin;
     this.type               = (JobTypes)json.type;
     this.role               = (RoleTypes)json.role;
     this.wepmdl             = json.wepmdl;
     this.mov                = (OInt)json.jmov;
     this.jmp                = (OInt)json.jjmp;
     this.atkskill[0]        = string.IsNullOrEmpty(json.atkskl) ? string.Empty : json.atkskl;
     this.atkskill[1]        = string.IsNullOrEmpty(json.atkfi) ? string.Empty : json.atkfi;
     this.atkskill[2]        = string.IsNullOrEmpty(json.atkwa) ? string.Empty : json.atkwa;
     this.atkskill[3]        = string.IsNullOrEmpty(json.atkwi) ? string.Empty : json.atkwi;
     this.atkskill[4]        = string.IsNullOrEmpty(json.atkth) ? string.Empty : json.atkth;
     this.atkskill[5]        = string.IsNullOrEmpty(json.atksh) ? string.Empty : json.atksh;
     this.atkskill[6]        = string.IsNullOrEmpty(json.atkda) ? string.Empty : json.atkda;
     this.fixed_ability      = json.fixabl;
     this.artifact           = json.artifact;
     this.ai                 = json.ai;
     this.master             = json.master;
     this.MapEffectAbility   = json.me_abl;
     this.IsMapEffectRevReso = json.is_me_rr != 0;
     this.DescCharacteristic = json.desc_ch;
     this.DescOther          = json.desc_ot;
     Array.Clear((Array)this.ranks, 0, this.ranks.Length);
     if (json.ranks != null)
     {
         for (int index = 0; index < json.ranks.Length; ++index)
         {
             this.ranks[index] = new JobRankParam();
             if (!this.ranks[index].Deserialize(json.ranks[index]))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        public IEnumerable<string> GetRoles(string userName, RoleTypes roleType)
        {
            var returnedRoles = new List<string>();

            using (PrincipalContext context = GetPrincipalContext())
            {
                // find the user in the identity store
                UserPrincipal user = UserPrincipal.FindByIdentity(context, userName);

                // get the groups for the user principal and
                // store the results in a PrincipalSearchResult object
                PrincipalSearchResult<Principal> results = user.GetGroups();

                results.ToList().ForEach(result => returnedRoles.Add(result.Name));
            }
            return returnedRoles;
        }
        public IEnumerable<string> GetRoles(string userName, RoleTypes roleType)
        {
            if (roleType == RoleTypes.IdentityServer)
            {
                UserAccountEntity account = null;
                if (TryGetUserAccount(userName, out account))
                {
                    if (!string.IsNullOrWhiteSpace(account.InternalRoles))
                    {
                        var roles = account.InternalRoles.Split(',');
                        return new List<string>(from r in roles select r);
                    }

                }
            }

            return new string[] { };
        }
예제 #33
0
        public IEnumerable<string> GetRoles(string userName, RoleTypes roleType)
        {
            var returnedRoles = new List<string>();

            if (Roles.Enabled)
            {
                var roles = Roles.GetRolesForUser(userName);

                if (roleType == RoleTypes.All)
                {
                    returnedRoles = roles.ToList();
                }
                else if (roleType == RoleTypes.IdentityServer)
                {
                    returnedRoles = roles.Where(role => role.StartsWith(Constants.Roles.InternalRolesPrefix)).ToList();
                }
                else if (roleType == RoleTypes.Client)
                {
                    returnedRoles = roles.Where(role => !(role.StartsWith(Constants.Roles.InternalRolesPrefix))).ToList();
                }
            }

            return returnedRoles;
        }
예제 #34
0
 public IEnumerable<string> GetRoles(string userName, RoleTypes roleType)
 {
     if (roleType == RoleTypes.IdentityServer || roleType == RoleTypes.All)
     {
         yield return Constants.Roles.IdentityServerAdministrators;
         yield return Constants.Roles.Administrators;
     }
     else if (roleType == RoleTypes.Client)
     {
         yield return Constants.Roles.Administrators;
     }
 }