function down()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Simpleauth', $drivers)) {
         // get the tablename
         \Config::load('simpleauth', true);
         $basetable = \Config::get('simpleauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('simpleauth.db_connection', null));
     } elseif (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $basetable = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
     } else {
         $basetable = 'users';
     }
     \DBUtil::drop_table($basetable . '_sessionscopes');
     \DBUtil::drop_table($basetable . '_sessions');
     \DBUtil::drop_table($basetable . '_scopes');
     \DBUtil::drop_table($basetable . '_clients');
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
Example #2
0
 /**
  * Class initialisation
  */
 public static function _init()
 {
     // just checkin', do we have Opauth installed?
     if (!class_exists('Opauth')) {
         throw new \OpauthException('Opauth composer package not installed. Add "opauth/opauth" to composer.json and run a composer update.');
     }
     // load the auth and opauth config
     \Config::load('auth', true);
     \Config::load('opauth', true);
     // get the auth driver in use
     $drivers = normalize_driver_types();
     // determine the auth driver we're going to use
     if (in_array('Simpleauth', $drivers)) {
         // get the tablename
         \Config::load('simpleauth', true);
         static::$provider_table = \Config::get('simpleauth.table_name', 'users') . '_providers';
         static::$db_connection = \Config::get('simpleauth.db_connection', null);
     } elseif (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         static::$provider_table = \Config::get('ormauth.table_name', 'users') . '_providers';
         static::$db_connection = \Config::get('ormauth.db_connection', null);
     } else {
         throw new \OpauthException('No supported driver found. Opauth currently only supports Simpleauth and Ormauth.');
     }
 }
 function down()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
         // drop the admin_users_perms table
         \DBUtil::drop_table($table . '_permissions');
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
Example #4
0
 /**
  * init the class
  */
 public static function _init()
 {
     // auth config
     \Config::load('auth', true);
     // get the auth driver in use
     $drivers = normalize_driver_types();
     // modify the model definition based on the driver used
     if (in_array('Simpleauth', $drivers)) {
         // remove properties not in use
         unset(static::$_properties['group_id']);
         unset(static::$_properties['previous_login']);
         unset(static::$_properties['user_id']);
         // remove relations
         static::$_eav = array();
         static::$_belongs_to = array();
         static::$_has_many = array();
         static::$_many_many = array();
         // remove observers
         unset(static::$_observers['Orm\\Observer_Self']);
         // simpleauth config
         \Config::load('simpleauth', true);
         // set the connection this model should use
         static::$_connection = \Config::get('simpleauth.db_connection');
         // set the write connection this model should use
         static::$_write_connection = \Config::get('simpleauth.db_write_connection') ?: static::$_connection;
         // set the models table name
         static::$_table_name = \Config::get('simpleauth.table_name', 'users');
     } elseif (in_array('Ormauth', $drivers)) {
         // remove properties not in use
         unset(static::$_properties['group']);
         unset(static::$_properties['profile_fields']);
         // ormauth config
         \Config::load('ormauth', true);
         // set the connection this model should use
         static::$_connection = \Config::get('ormauth.db_connection');
         // set the write connection this model should use
         static::$_write_connection = \Config::get('ormauth.db_write_connection') ?: static::$_connection;
         // set the models table name
         static::$_table_name = \Config::get('ormauth.table_name', 'users');
         // set the relations through table names
         static::$_many_many['roles']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_roles';
         static::$_many_many['permissions']['table_through'] = \Config::get('ormauth.table_name', 'users') . '_user_permissions';
     }
     // model language file
     \Lang::load('auth_model_user', true);
 }
 function down()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection($connection = \Config::get('ormauth.db_connection', null));
         // modify the filter field to add the 'remove' filter
         \DB::update($table . '_roles')->set(array('filter' => 'D'))->where('filter', '=', 'R')->execute($connection);
         \DBUtil::modify_fields($table . '_roles', array('filter' => array('type' => 'enum', 'constraint' => "'', 'A', 'D'", 'default' => '')));
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
 function down()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users');
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
         // empty the user, group and role tables
         \DBUtil::truncate_table($table);
         \DBUtil::truncate_table($table . '_groups');
         \DBUtil::truncate_table($table . '_roles');
         \DBUtil::truncate_table($table . '_group_roles');
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }
 function down()
 {
     // get the drivers defined
     $drivers = normalize_driver_types();
     if (in_array('Simpleauth', $drivers)) {
         // get the tablename
         \Config::load('simpleauth', true);
         $table = \Config::get('simpleauth.table_name', 'users') . '_providers';
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('simpleauth.db_connection', null));
     } elseif (in_array('Ormauth', $drivers)) {
         // get the tablename
         \Config::load('ormauth', true);
         $table = \Config::get('ormauth.table_name', 'users') . '_providers';
         // make sure the configured DB is used
         \DBUtil::set_connection(\Config::get('ormauth.db_connection', null));
     }
     if (isset($table)) {
         // drop the users remote table
         \DBUtil::drop_table($table);
     }
     // reset any DBUtil connection set
     \DBUtil::set_connection(null);
 }