Example #1
0
 public ClanMember(string nickname, int profileID, int experience, int clanPoints, DateTimeOffset inviteDate, ClanRole clanRole, string jid, PlayerStatus status) :
     base(nickname, profileID, jid, status, experience)
 {
     ClanPoints = clanPoints;
     InviteDate = inviteDate;
     ClanRole   = clanRole;
 }
Example #2
0
 public PeerPlayerInfo(string onlineId, string nickname, string primaryWeapon, string primaryWeaponSkin, string bannerBadge, string bannerMark, string bannerStripe, int experience, int pvpRatingRank, int itemsUnlocked, int challengesCompleted, int?missionsCompleted, int?pvpWins, int?pvpLoses, int?pvpTotalMatches, int?pvpKills, int?pvpDeaths, int?playtimeSeconds, float?leavingsPercentage, int?coopClimbsPerformed, int?coopAssistsPerformed, Class?favoritePvpClass, Class?favoritePveClass, string clanName, ClanRole clanRole, int clanPosition, int clanPoints, DateTimeOffset clanMemberSince)
 {
     OnlineId             = onlineId;
     Nickname             = nickname;
     PrimaryWeapon        = primaryWeapon;
     PrimaryWeaponSkin    = primaryWeaponSkin;
     BannerBadge          = bannerBadge;
     BannerMark           = bannerMark;
     BannerStripe         = bannerStripe;
     Experience           = experience;
     PvpRatingRank        = pvpRatingRank;
     ItemsUnlocked        = itemsUnlocked;
     MissionsCompleted    = missionsCompleted;
     PvpWins              = pvpWins;
     PvpLoses             = pvpLoses;
     PvpTotalMatches      = pvpTotalMatches;
     PvpKills             = pvpKills;
     PvpDeaths            = pvpDeaths;
     PlaytimeSeconds      = playtimeSeconds;
     LeavingsPercentage   = leavingsPercentage;
     CoopClimbsPerformed  = coopClimbsPerformed;
     CoopAssistsPerformed = coopAssistsPerformed;
     FavoritePvpClass     = favoritePvpClass;
     FavoritePveClass     = favoritePveClass;
     _clanName            = clanName;
     _clanRole            = clanRole;
     _clanPosition        = clanPosition;
     _clanPoints          = clanPoints;
     _clanMemberSince     = clanMemberSince;
     ChallengesCompleted  = challengesCompleted;
     ItemsUnlocked        = itemsUnlocked;
 }
Example #3
0
 public void Update(ClanMember newClanMemberEntry)
 {
     Experience = newClanMemberEntry.Experience;
     ClanPoints = newClanMemberEntry.ClanPoints;
     ClanRole   = newClanMemberEntry.ClanRole;
     JID        = newClanMemberEntry.JID;
     Status     = newClanMemberEntry.Status;
 }
 protected void Select(ClanRole role)
 {
     if (role == ClanRole.LEADER && Role != role)
     {
         NotificationService.ShowWarning("You will loose your role as leader as soon as you assign it!");
     }
     Role = role;
 }
Example #5
0
    public void SetClan(Clan clan, ClanRole role)
    {
        InClan   = clan != null;
        ClanInfo = clan;
        Role     = role;

        if (InClan && !string.IsNullOrEmpty(clan.Owner))
        {
            Logo = clan.Logo ?? (PlayerLogoManager.TwitchLogoUrl + clan.Owner);
        }
        else
        {
            Logo = null;
        }

        if (clan != null && gameManager != null && gameManager.Clans != null)
        {
            gameManager.Clans.RegisterClan(clan);
        }
    }
		public static ClanRole GetCurrentLoginClanRole(this HttpContextBase context)
		{
			ClanRole clanUserRole = ClanRole.Unknown;

			if (context.Session[_sessionMemberRole] != null)
			{
				clanUserRole = (ClanRole)context.Session[_sessionMemberRole];
			}

			if (clanUserRole == ClanRole.Unknown)
			{
				var clanUser = GetCurrentLoginInformation(context);

				if (clanUser != null && clanUser.id > 0)
				{
					context.Session.Add(_sessionMemberRole, clanUser.userRoleId);
					clanUserRole = (ClanRole)clanUser.userRoleId;
				}
			}

			return clanUserRole;
		}
        override public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                bool authorized = false;

                if (_adminOnly && HttpContext.Current.User.IsInRole(_aspRoleAdmin))
                {
                    authorized = true;
                }
                else if (this.RequiredPermission != null && this.RequiredPermission.Any() && this.RequiredPermission.Length > 0)
                {
                    ClanRole userRole = filterContext.HttpContext.GetCurrentLoginClanRole();

                    foreach (var role in this.RequiredPermission)
                    {
                        //TODO //vv can we get the roles from AspNetRoles? so we can check it here, instead of being hardcoded
                        if (HttpContext.Current.User.IsInRole(_aspRoleAdmin) || role == userRole.ToString())
                        {
                            authorized = true;
                        }
                    }
                }

                //	//TODO //vv filterContext.Result = redirect to some custom unauthorize page
                if (!authorized)
                {
                    var url      = new UrlHelper(filterContext.RequestContext);
                    var logonUrl = url.Action("Http", "Error", new { Id = 401, Area = "" });
                    filterContext.Result = new RedirectResult(logonUrl);
                }
            }
            else
            {
                filterContext.Result = new HttpUnauthorizedResult();
            }
        }
 public AuthorizeUserAttribute(ClanRole clanUserRole)
     : this(new object[] { clanUserRole })
 {
 }
Example #9
0
 public PeerClanMemberUpdate(string nickname, int profileID, PlayerStatus status, int experience, string placeToken, string placeInfoToken, string modeInfoToken, string missionInfoToken, int clanPoints, ClanRole role) : base(nickname, profileID, status, experience, placeToken, placeInfoToken, modeInfoToken, missionInfoToken)
 {
     ClanPoints = clanPoints;
     Role       = role;
 }
Example #10
0
 public void Update(PeerClanMemberUpdate update, string jid)
 {
     base.Update(update, jid);
     ClanPoints = update.ClanPoints;
     ClanRole   = update.Role;
 }
 public AuthorizeUserAttribute(ClanRole clanUserRole) : this(new object[] { clanUserRole })
 {
 }
Example #12
0
        public static async Task <ValidatedView> AssignRole(int accountId, int targetId, ClanRole role)
        {
            try {
                ClanMemberModel clanMemberModel = await Model <ClanMemberModel>
                                                  .AsQueryable().FirstOrDefault(x => x.AccountID == accountId);

                if (clanMemberModel != null)
                {
                    ClanModel clanModel = await Model <ClanModel> .AsQueryable()
                                          .FirstOrDefault(x => x.ID == clanMemberModel.ClanID);

                    if (clanModel == null)
                    {
                        return(ValidatedView.Invalid(ErrorCode.CLAN_NOT_FOUND));
                    }
                    else
                    {
                        ClanMemberModel targetMemberModel = await Model <ClanMemberModel>
                                                            .AsQueryable()
                                                            .FirstOrDefault(x => x.AccountID == targetId && x.ClanID == clanModel.ID);

                        if (targetMemberModel == null)
                        {
                            return(ValidatedView.Invalid(ErrorCode.CLAN_TARGET_NOT_MEMBER));
                        }

                        if (targetMemberModel.Role == ClanRole.LEADER ||
                            clanMemberModel.Role < ClanRole.VICE_LEADER ||
                            clanMemberModel.Role < role)
                        {
                            return(ValidatedView.Invalid(ErrorCode.CLAN_MANAGE_MEMBER_INSUFFICIENT_RIGHTS));
                        }

                        if (targetMemberModel.Role == role)
                        {
                            return(ValidatedView.Valid());
                        }

                        targetMemberModel.Role = role;
                        await Model <ClanMemberModel> .AsCollection().ReplaceOneAsync(x =>
                                                                                      x.AccountID == targetId && x.ClanID == clanModel.ID, targetMemberModel);

                        if (role == ClanRole.LEADER)
                        {
                            clanMemberModel.Role = ClanRole.VICE_LEADER;
                            await Model <ClanMemberModel> .AsCollection().ReplaceOneAsync(x =>
                                                                                          x.AccountID == accountId && x.ClanID == clanModel.ID, clanMemberModel);
                        }

                        return(ValidatedView.Valid());
                    }
                }
                else
                {
                    return(ValidatedView.Invalid(ErrorCode.CLAN_NOT_MEMBER));
                }
            } catch (Exception e) {
                GameContext.Logger.LogError(e);
            }
            return(ValidatedView.Invalid(ErrorCode.OPERATION_FAILED));
        }