Authenticating using Sitemagic CMS

The framework features the SMAuthentication class which is used by the SMLogin extension to log in and out of the control panel, as well as check whether the current user is actually logged in. This is useful to prevent access to administration features as the following code demonstrates:
// Take user back to front page if trying to access extension by manipulating the URL.
// This should ONLY be done during the Render stages. If done using one of the other
// stages, the user will continuously be redirected back to the front page, since the life
// cycle stages is always executed for all extensions, while the Render stage is only
// executed for the privileged extension.

public function Render()
    // Take user back to the default extension if not logged in
    // (which is usually the SMPages extension displaying the front page by default).
    if (SMAuthentication::Authorized() === false)

    // User logged in - return administration GUI
    return someFunctionBuildingTheAdminGui();
The check can obviously also be used to skip code during the other stages of the life cycle, if it should only run when the user is logged in to the control panel.
public function Init()
    // Prevent code within Init stage to execute if user is not logged in
    if (SMAuthentication::Authorized() === false)

    // Execute code here, supposed to do something during the Init stage if user is logged in..