mattrobineau / stories

Community driven link aggregater for .Net written in C#
MIT License
1 stars 1 forks source link

Refactor Story and Comment validators #36

Closed mattrobineau closed 7 years ago

mattrobineau commented 7 years ago

Instead of validating users in the story and comment validators eg:

var user = Task.Run(async () => await UserService.GetUser(instance.UserId)).Result;

            if (user == null)
            {
                result.IsValid = false;
                result.Messages.Add("Error: Please sign in again.");
            }

            if (user.IsBanned)
            {
                result.IsValid = false;
                result.Messages.Add("You account is banned.");
                return result;
            }

Validate the users using a user specific validator in the controller actions.