Here is the cut down version of my original code.
There are other classes which subclass which inherits from Controller. But with this example ive shown UserController. As you can see, what i was trying to do is to put the common code to the superclass Controller and generalise it, such that it can be used by other classes.
Also why dont I have an option to edit my posts after being posted?