} } /* Import UserFrosting variables as global Twig variables */ $twig = $app->view()->getEnvironment(); $twig->addFilter(new \Twig_SimpleFilter('cast_to_array', function ($stdClassObject) { $response = array(); foreach ((array) $stdClassObject as $key => $value) { $response[str_replace('*', '', $key)] = $value; } return $response; })); $loader = $twig->getLoader(); // First look in user's theme... $loader->addPath($app->config('plugins.path') . "/UserFrosting-OAuth/templates"); $table_user_oauth = new UF\DatabaseTable($app->config('db')['db_prefix'] . "user_oauth", ["provider", "user_id", "uid", "email", "first_name", "last_name", "picture_url", "oauth_details", "created_at"]); UF\Database::setSchemaTable("user_oauth", $table_user_oauth); // Define routes // This is the GET route for the "login with ___" button $app->get('/oauth/:provider/login', function ($provider) use($app) { $controller = getProviderController($provider, 'login', $app); // Store this action so we remember what we're doing after we get the authorization code $_SESSION['oauth_action'] = "login"; $get = $app->request->get(); // If we received an authorization code, then resume our action if (isset($get['code'])) { // If we're logging them in, just call that method and it will automatically redirect us $controller->login(); } else { // Otherwise, request an authorization code return $controller->authorize(); }
\UserFrosting\UFModel::$app = $app; // Initialize database properties $table_user = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "user", ["user_name", "display_name", "email", "title", "locale", "primary_group_id", "secret_token", "flag_verified", "flag_enabled", "flag_password_reset", "created_at", "updated_at", "password"]); $table_user_event = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "user_event", ["user_id", "event_type", "occurred_at", "description"]); $table_group = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "group", ["name", "is_default", "can_delete", "theme", "landing_page", "new_user_title", "icon"]); $table_group_user = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "group_user"); $table_configuration = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "configuration"); $table_authorize_user = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "authorize_user"); $table_authorize_group = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "authorize_group"); \UserFrosting\Database::setSchemaTable("user", $table_user); \UserFrosting\Database::setSchemaTable("user_event", $table_user_event); \UserFrosting\Database::setSchemaTable("group", $table_group); \UserFrosting\Database::setSchemaTable("group_user", $table_group_user); \UserFrosting\Database::setSchemaTable("configuration", $table_configuration); \UserFrosting\Database::setSchemaTable("authorize_user", $table_authorize_user); \UserFrosting\Database::setSchemaTable("authorize_group", $table_authorize_group); // Info for RememberMe table $app->remember_me_table = ['tableName' => $app->config('db')['db_prefix'] . "user_rememberme", 'credentialColumn' => 'user_id', 'tokenColumn' => 'token', 'persistentTokenColumn' => 'persistent_token', 'expiresColumn' => 'expires']; /* Event Types "sign_up", "sign_in", "verification_request", "password_reset_request", */ /* Load UserFrosting site settings */ // Default settings $setting_values = ['userfrosting' => ['site_title' => 'UserFrosting', 'admin_email' => '*****@*****.**', 'email_login' => '1', 'can_register' => '1', 'enable_captcha' => '1', 'require_activation' => '1', 'resend_activation_threshold' => '0', 'reset_password_timeout' => '10800', 'create_password_expiration' => '86400', 'default_locale' => 'en_US', 'guest_theme' => 'default', 'minify_css' => '0', 'minify_js' => '0', 'version' => '0.3.1.10', 'author' => 'Alex Weissman', 'show_terms_on_register' => '1', 'site_location' => 'The State of Indiana']]; $setting_descriptions = ['userfrosting' => ["site_title" => "The title of the site. By default, displayed in the title tag, as well as the upper left corner of every user page.", "admin_email" => "The administrative email for the site. Automated emails, such as verification emails and password reset links, will come from this address.", "email_login" => "Specify whether users can login via email address or username instead of just username.", "can_register" => "Specify whether public registration of new accounts is enabled. Enable if you have a service that users can sign up for, disable if you only want accounts to be created by you or an admin.", "enable_captcha" => "Specify whether new users must complete a captcha code when registering for an account.", "require_activation" => "Specify whether email verification is required for newly registered accounts. Accounts created by another user never need to be verified.", "resend_activation_threshold" => "The time, in seconds, that a user must wait before requesting that the account verification email be resent.", "reset_password_timeout" => "The time, in seconds, before a user's password reset token expires.", "create_password_expiration" => "The time, in seconds, before a new user's password creation token expires.", "default_locale" => "The default language for newly registered users.", "guest_theme" => "The template theme to use for unauthenticated (guest) users.", "minify_css" => "Specify whether to use concatenated, minified CSS (production) or raw CSS includes (dev).", "minify_js" => "Specify whether to use concatenated, minified JS (production) or raw JS includes (dev).", "version" => "The current version of UserFrosting.", "author" => "The author of the site. Will be used in the site's author meta tag.", "show_terms_on_register" => "Specify whether or not to show terms and conditions when registering.", "site_location" => "The nation or state in which legal jurisdiction for this site falls."]]; // Create the site settings object. If the database cannot be accessed or has not yet been set up, use the default settings. $app->site = new \UserFrosting\SiteSettings($setting_values, $setting_descriptions); // Create the page schema object
$table_car = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "car", ["created_at", "updated_at", "user_id", "title", "email", "phone", "maxPassengerCount"]); $table_group_user = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "group_user"); $table_configuration = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "configuration"); $table_authorize_user = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "authorize_user"); $table_authorize_group = new \UserFrosting\DatabaseTable($app->config('db')['db_prefix'] . "authorize_group"); \UserFrosting\Database::setSchemaTable("user", $table_user); \UserFrosting\Database::setSchemaTable("user_event", $table_user_event); \UserFrosting\Database::setSchemaTable("group", $table_group); \UserFrosting\Database::setSchemaTable("group_user", $table_group_user); \UserFrosting\Database::setSchemaTable("configuration", $table_configuration); \UserFrosting\Database::setSchemaTable("authorize_user", $table_authorize_user); \UserFrosting\Database::setSchemaTable("authorize_group", $table_authorize_group); \UserFrosting\Database::setSchemaTable("booking", $table_booking); \UserFrosting\Database::setSchemaTable("geolock", $table_geolock); \UserFrosting\Database::setSchemaTable("pricing", $table_pricing); \UserFrosting\Database::setSchemaTable("car", $table_car); // Info for RememberMe table $app->remember_me_table = ['tableName' => $app->config('db')['db_prefix'] . "user_rememberme", 'credentialColumn' => 'user_id', 'tokenColumn' => 'token', 'persistentTokenColumn' => 'persistent_token', 'expiresColumn' => 'expires']; /* Event Types "sign_up", "sign_in", "verification_request", "password_reset_request", */ /* Load UserFrosting site settings */ // Default settings $setting_values = ['userfrosting' => ['site_title' => 'Taxibo', 'admin_email' => '*****@*****.**', 'email_login' => '1', 'can_register' => '0', 'enable_captcha' => '1', 'require_activation' => '1', 'resend_activation_threshold' => '0', 'reset_password_timeout' => '10800', 'create_password_expiration' => '86400', 'default_locale' => 'sv_SE', 'guest_theme' => 'default', 'minify_css' => '0', 'minify_js' => '0', 'version' => '0.3.1.11', 'author' => 'Allan Th. Andersen', 'show_terms_on_register' => '1', 'site_location' => 'Scandinavia - Denmark/Sweden/Norge']]; $setting_descriptions = ['userfrosting' => ["site_title" => "The title of the site. By default, displayed in the title tag, as well as the upper left corner of every user page.", "admin_email" => "The administrative email for the site. Automated emails, such as verification emails and password reset links, will come from this address.", "email_login" => "Specify whether users can login via email address or username instead of just username.", "can_register" => "Specify whether public registration of new accounts is enabled. Enable if you have a service that users can sign up for, disable if you only want accounts to be created by you or an admin.", "enable_captcha" => "Specify whether new users must complete a captcha code when registering for an account.", "require_activation" => "Specify whether email verification is required for newly registered accounts. Accounts created by another user never need to be verified.", "resend_activation_threshold" => "The time, in seconds, that a user must wait before requesting that the account verification email be resent.", "reset_password_timeout" => "The time, in seconds, before a user's password reset token expires.", "create_password_expiration" => "The time, in seconds, before a new user's password creation token expires.", "default_locale" => "The default language for newly registered users.", "guest_theme" => "The template theme to use for unauthenticated (guest) users.", "minify_css" => "Specify whether to use concatenated, minified CSS (production) or raw CSS includes (dev).", "minify_js" => "Specify whether to use concatenated, minified JS (production) or raw JS includes (dev).", "version" => "The current version of UserFrosting.", "author" => "The author of the site. Will be used in the site's author meta tag.", "show_terms_on_register" => "Specify whether or not to show terms and conditions when registering.", "site_location" => "The nation or state in which legal jurisdiction for this site falls."]]; // Create the site settings object. If the database cannot be accessed or has not yet been set up, use the default settings. $app->site = new \UserFrosting\SiteSettings($setting_values, $setting_descriptions); // Create the page schema object