refactoring

extracted logic from PostsController to Posts class

now check if user is unauthorized when they create a post