示例#1
0
        public override IEnumerable <ValidationResult> Validate()
        {
            yield return(TfValidationResult.CheckSessionActivity(this.SessionId, this.SessionKey));

            if (this.Handling)
            {
                TfValidationResult.FieldRequired(nameof(this.GroupId), this.GroupId);
                TfValidationResult.FieldRequired(nameof(this.Message), this.Message);
            }
        }
示例#2
0
        public override IEnumerable <ValidationResult> Validate()
        {
            yield return(TfValidationResult.CheckSessionActivity(this.SessionId, this.SessionKey));

            yield return(TfValidationResult.FieldRequired(nameof(this.Username), this.Username));

            if (CheckAdd.CheckContactExists(this.SessionId, this.Username))
            {
                yield return(TfValidationResult.Compose("ContactExists", nameof(this.Username)));
            }
        }
示例#3
0
        public override IEnumerable <ValidationResult> Validate()
        {
            yield return(TfValidationResult.CheckSessionActivity(this.SessionId, this.SessionKey));

            if (this.Handling)
            {
                yield return(TfValidationResult.FieldRequired(nameof(this.GroupName), this.GroupName));

                yield return(TfValidationResult.FieldRequired(nameof(this.Members), this.Members));

                if (this.Members != null && this.Members.Count > 0)
                {
                    foreach (var member in this.Members)
                    {
                        if (!CheckMember.CheckUsernameExists(member))
                        {
                            yield return(TfValidationResult.Compose("UsernameNotExists", new[] { member }, nameof(this.Members)));
                        }
                    }
                }
            }
        }
示例#4
0
        protected bool Authorize(bool validate)
        {
            if (!validate)
            {
                return(true);
            }

            var accesses = Schemas.Accesses;

            if (TfSettings.System.Debug)
            {
                accesses.Entity.key    = TfSettings.System.DefaultKey;
                accesses.Entity.secret = TfSettings.System.DefaultSecret;
                if (accesses.Count == 0)
                {
                    var uri = new Uri(TfSettings.Web.ApiUrl);
                    accesses.Insert();
                }
            }

            var authorizationString = this.Request.Headers["Authorization"].ToString().Split(" ");

            if (authorizationString.Count() != 2)
            {
                return(this.Unauthorize());
            }

            var sessionId  = authorizationString[0];
            var sessionKey = authorizationString[1];
            var validation = TfValidationResult.CheckSessionActivity(sessionId, sessionKey);

            if (validation != null)
            {
                return(this.Unauthorize());
            }

            return(true);
        }
示例#5
0
 public override IEnumerable <ValidationResult> Validate()
 {
     yield return(TfValidationResult.CheckSessionActivity(this.SessionId, this.SessionKey));
 }