Moves rank calculation to a helper method

This PR uses a helper method to calculate the user's rank, redirecting to homepage if the user is not logged in.
Ref #102