Model_Auth_User_Token::create_token PHP Method

create_token() public method

Finds a new unique token, using a loop to make sure that the token does not already exist in the database. This could potentially become an infinite loop, but the chances of that happening are very unlikely.
public create_token ( ) : string
return string
    public function create_token()
    {
        while (TRUE) {
            // Create a random token
            $token = text::random('alnum', 32);
            // Make sure the token does not already exist
            if (!Jelly::select('user_token')->where('token', '=', $token)->count()) {
                // A unique token has been found
                return $token;
            }
        }
    }