Ejemplo n.º 1
0
 function postUpdate($id = 0, &$data)
 {
     $groupName = trim(Input::get('name'));
     if ($id == 0) {
         try {
             // Create the group
             $group = Sentry::createGroup(array('name' => $groupName));
             $data['id'] = $group->id;
             $data['status'] = TRUE;
         } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
             $data['message'] = "Vui lòng nhập tên nhóm";
         } catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
             $data['message'] = "Tên nhóm đã tồn tại. Vui lòng nhập tên nhóm khác";
         }
     } else {
         try {
             // Find the group using the group id
             $group = Sentry::findGroupById($id);
             // Update the group details
             $group->name = $groupName;
             if ($group->save()) {
                 $data['status'] = TRUE;
             }
         } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
             $data['message'] = "Vui lòng nhập tên nhóm";
         } catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
             $data['message'] = "Tên nhóm đã tồn tại. Vui lòng nhập tên nhóm khác";
         } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
             $data['message'] = "Nhóm không tồn tại";
         }
     }
 }
Ejemplo n.º 2
0
 public function run()
 {
     //Hapus isi table users, groups, users_groups dan Throttle
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         //Membuat grup admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
     try {
         //Membuat admin baru
         $admin = Sentry::register(array('username' => 'admin', 'password' => 'admin', 'first_name' => 'Admin', 'last_name' => 'Koperasi'), true);
         //Langsung diaktivasi
         //Cari Group Admin
         $adminGroup = Sentry::findGroupByName('admin');
         //Masukkan user ke Group admin
         $admin->addGroup($adminGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo 'Password field is required.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo 'User with this login already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         //membuat group admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         //membuat group guru
         $guru = Sentry::createGroup(array('name' => 'guru', 'permissions' => array('guru' => 1)));
         //membuat group siswa
         $siswa = Sentry::createGroup(array('name' => 'siswa', 'permissions' => array('siswa' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo "Nama Group harus diisi";
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo "Group Sudah Ada";
     }
     try {
         //membuat admin baru
         $admin = Sentry::register(array('password' => 'admin123', 'username' => 'Admin'), true);
         //cari group admin
         $adminGroup = Sentry::findGroupByName('admin');
         //masukan user ke group admin
         $admin->addGroup($adminGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo "Field login harus diisi";
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo "Password harus diisi";
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo "User dengan akun ini sudah ada";
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo "Group tidak ada";
     }
 }
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         $group = Sentry::createGroup(array('name' => 'administrator', 'description' => 'Administrator', 'permissions' => array('admin' => 1)));
         $group = Sentry::createGroup(array('name' => 'operator', 'description' => 'Operator', 'permissions' => array('operator' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo "Name file is Required";
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo "Group already exists";
     }
     try {
         $admin = Sentry::register(array('email' => '*****@*****.**', 'password' => 'admin', 'first_name' => 'Administrator', 'last_name' => 'IT KSA'), true);
         $adminGroup = Sentry::findGroupByName('administrator');
         $admin->addGroup($adminGroup);
         $operator = Sentry::register(array('email' => '*****@*****.**', 'password' => '090996o9o9g6!@#', 'first_name' => 'Operator', 'last_name' => 'IT KSA'), true);
         $operatorGroup = Sentry::findGroupByName('operator');
         $operator->addGroup($operatorGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo "Login field is required";
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo "Password field is required";
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo "User with this login is Required";
     } catch (Cartalyst\Sentry\Users\GroupNotFoundException $e) {
         echo "Group was not found";
     }
 }
 public function run()
 {
     DB::table('groups')->truncate();
     $admin = Sentry::createGroup(array('name' => 'Manager', 'permissions' => []));
     $staff = Sentry::createGroup(array('name' => 'Store Manager', 'permissions' => []));
     $staff = Sentry::createGroup(array('name' => 'Sales Person', 'permissions' => []));
     \Mualnuam\Permission::revoke();
 }
Ejemplo n.º 6
0
 /**
  * Create roles if they don't exist already
  *
  */
 protected function createGroup($name)
 {
     try {
         $group = \Sentry::createGroup(['name' => $name, 'permissions' => ['superuser' => 1]]);
     } catch (\Exception $e) {
         // this group probably already exists... so ignore the exception
     }
 }
Ejemplo n.º 7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ID 1
     $admin = \Sentry::register(['email' => env('ADMIN_EMAIL'), 'password' => env('ADMIN_PASSWORD'), 'timezone' => env('ADMIN_TIMEZONE')], true);
     // ID 1
     $adminGroup = \Sentry::createGroup(array('name' => 'Superuser', 'permissions' => array('superuser' => 1)));
     $admin->addGroup($adminGroup);
 }
Ejemplo n.º 8
0
 public function run()
 {
     Sentry::createGroup(array('name' => 'Carga Inicial'));
     Sentry::createGroup(array('name' => 'Trabajador Social'));
     Sentry::createGroup(array('name' => 'Autorizador'));
     Sentry::createGroup(array('name' => 'Administrador'));
     //, 'permissions' => '{"superuser":1}'
 }
 public function run()
 {
     DB::table('groups')->delete();
     Sentry::createGroup(array('name' => 'administrador', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'users_index' => 1, 'users_create' => 1, 'users_update' => 1, 'users_delete' => 1, 'groups_index' => 1, 'groups_create' => 1, 'groups_update' => 1, 'groups_delete' => 1, 'profiles_index' => 1, 'profiles_create' => 1, 'profiles_update' => 1, 'profiles_delete' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
     Sentry::createGroup(array('name' => 'director', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'users_index' => 1, 'users_create' => 1, 'users_update' => 1, 'users_delete' => 1, 'groups_index' => 1, 'groups_create' => 1, 'groups_update' => 1, 'groups_delete' => 1, 'profiles_index' => 1, 'profiles_create' => 1, 'profiles_update' => 1, 'profiles_delete' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
     Sentry::createGroup(array('name' => 'secretaria', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'users_index' => 1, 'users_create' => 1, 'users_update' => 1, 'users_delete' => 1, 'groups_index' => 1, 'groups_create' => 1, 'groups_update' => 1, 'groups_delete' => 1, 'profiles_update' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
     Sentry::createGroup(array('name' => 'practicante', 'permissions' => array('admin' => 1, 'deeds_index' => 1, 'deeds_create' => 1, 'deeds_update' => 1, 'deeds_delete' => 1, 'agrarians_index' => 1, 'agrarians_create' => 1, 'agrarians_update' => 1, 'agrarians_delete' => 1, 'civils_index' => 1, 'civils_create' => 1, 'civils_update' => 1, 'civils_delete' => 1, 'penals_index' => 1, 'penals_create' => 1, 'penals_update' => 1, 'penals_delete' => 1, 'records_index' => 1, 'records_create' => 1, 'records_update' => 1, 'records_delete' => 1, 'notaries_index' => 1, 'notaries_create' => 1, 'notaries_update' => 1, 'notaries_delete' => 1, 'municipalities_index' => 1, 'municipalities_create' => 1, 'municipalities_update' => 1, 'municipalities_delete' => 1, 'profiles_update' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
     Sentry::createGroup(array('name' => 'usuario', 'permissions' => array('users' => 1, 'deeds_index' => 1, 'agrarians_index' => 1, 'civils_index' => 1, 'penals_index' => 1, 'records_index' => 1, 'notaries_index' => 1, 'municipalities_index' => 1, 'profiles_update' => 1, 'comments_index' => 1, 'comments_create' => 1, 'comments_update' => 1, 'comments_delete' => 1)));
 }
Ejemplo n.º 10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //创建用户组
     Sentry::createGroup(array('name' => 'Admin', 'is_admin' => 1, 'permissions' => []));
     Sentry::createGroup(array('name' => 'Guest', 'is_admin' => 0, 'permissions' => []));
     $user = Sentry::createUser(array('email' => '*****@*****.**', 'username' => 'admin', 'password' => '123456', 'activated' => true));
     $adminGroup = Sentry::findGroupById(1);
     $user->addGroup($adminGroup);
     Uinfo::create(['uid' => $user->id]);
 }
Ejemplo n.º 11
0
 public function run()
 {
     DB::table('users')->delete();
     DB::table('groups')->delete();
     DB::table('users_groups')->delete();
     $user = Sentry::createUser(array('username' => 'superadmin', 'password' => 'ad123min', 'first_name' => 'Super', 'last_name' => 'Administrator', 'activated' => 1));
     $group = Sentry::createGroup(array('name' => 'Super Administrators', 'permissions' => array('superuser' => 1)));
     // Assign user permissions
     $userGroup = Sentry::findGroupById(1);
     $user->addGroup($userGroup);
 }
Ejemplo n.º 12
0
 /**
  * Create new random superuser.
  *
  * @param string $password
  *
  * @return \VisualAppeal\Connect\User
  */
 protected function createSuperuser($password = '******')
 {
     $lastLogin = $this->faker->dateTime();
     $admin = \Sentry::createUser(['email' => $this->faker->email, 'password' => $password, 'activated' => 1, 'activated_at' => $this->faker->dateTime($lastLogin), 'last_login' => $lastLogin, 'first_name' => $this->faker->firstName, 'last_name' => $this->faker->lastName]);
     try {
         $adminGroup = Sentry::findGroupById(1);
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         $adminGroup = Sentry::createGroup(['name' => 'Superuser', 'permissions' => ['superuser' => 1]]);
     }
     $admin->addGroup($adminGroup);
     return $admin;
 }
Ejemplo n.º 13
0
 public function run()
 {
     // 清空数据
     DB::table('users')->truncate();
     DB::table('groups')->truncate();
     DB::table('users_groups')->truncate();
     //创建用户组
     $group = Sentry::createGroup(array('name' => '管理员', 'permissions' => array('superuser' => '1')));
     // 创建用户
     $user = Sentry::createUser(array('email' => 'admin', 'password' => "123456", 'first_name' => 'admin', 'last_name' => '', 'activated' => 1));
     //关联用户组
     $user->addGroup($group);
 }
Ejemplo n.º 14
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     try {
         // Create the group
         $group = Sentry::createGroup(array('name' => Input::get('name'), 'permissions' => is_array(Input::get('permissions')) ? array_fill_keys(Input::get('permissions'), 1) : array()));
         return Redirect::route('admin.groups.index');
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         return Redirect::back()->withInput()->withErrors('Name field is required');
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         return Redirect::back()->withInput()->withErrors('Group already exists');
     }
 }
Ejemplo n.º 15
0
 public function run()
 {
     DB::table('users')->delete();
     DB::table('groups')->delete();
     DB::table('users_groups')->delete();
     Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'Transport', 'last_name' => 'Social', 'activated' => 1));
     Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => array('admin' => 1)));
     Sentry::createGroup(array('name' => 'Users', 'permissions' => array('admin' => 0, 'users' => 1)));
     // Assign user permissions
     $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**');
     $adminGroup = Sentry::getGroupProvider()->findByName('Admin');
     $adminUser->addGroup($adminGroup);
 }
Ejemplo n.º 16
0
 /**
  * Run the user seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('users')->delete();
     DB::table('groups')->delete();
     $defaultUser = Config::get('auth.default');
     if (is_array($defaultUser)) {
         $user = Sentry::register($defaultUser, true);
         echo "User {$defaultUser['email']} created with password {$defaultUser['password']}\n";
         $adminGroup = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         $user->addGroup($adminGroup);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     /*create the first user as super admin*/
     $user = Sentry::createUser(array('email' => '*****@*****.**', 'password' => 'test1234', 'activated' => true, 'first_name' => 'Amitav', 'last_name' => 'Roy'));
     $group = Sentry::createGroup(array('name' => 'Super Admin', 'permissions' => array('create_users' => 1, 'edit_users' => 1, 'delete_users' => 1, 'manage_users' => 1, 'manage_permissions' => 1)));
     $adminGroup = Sentry::findGroupById(1);
     $user->addGroup($adminGroup);
     /*create second user as admin*/
     $user = Sentry::createUser(array('email' => '*****@*****.**', 'password' => 'test1234', 'activated' => true, 'first_name' => 'Jhon', 'last_name' => 'Doe'));
     $group = Sentry::createGroup(array('name' => 'Administrator', 'permissions' => array('create_users' => 1, 'edit_users' => 1, 'delete_users' => 0, 'manage_users' => 0, 'manage_permissions' => 0)));
     $adminGroup = Sentry::findGroupById(2);
     $user->addGroup($adminGroup);
     $group = Sentry::createGroup(array('name' => 'Authenticated User'));
 }
Ejemplo n.º 18
0
 /**
  * Admin.group.create
  */
 public function postCreate()
 {
     // Set permission
     Auth::requirePermissions('admin.group.create');
     try {
         // Create the group
         $group = \Sentry::createGroup(array('name' => \Input::get('name')));
     } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
         Flash::set('Name is required');
     } catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
         Flash::set('A group with that name already exists');
     }
     return \Redirect::to('api/admin/groups');
 }
Ejemplo n.º 19
0
 public function run()
 {
     // Refresh groups
     DB::table('groups')->truncate();
     // Create the groups
     $groups = array(array('name' => 'User', 'permissions' => array('superuser' => 0, 'is_admin' => 0, 'login' => 0, 'register' => 0, 'all_public_pages' => 1, 'admin_panel' => 0), 'type' => 0, 'deletable' => 0), array('name' => 'Admin', 'permissions' => array('superuser' => 1, 'is_admin' => 1, 'login' => 0, 'register' => 0, 'all_public_pages' => 1, 'admin_panel' => 1), 'type' => 0, 'deletable' => 0));
     foreach ($groups as $group) {
         try {
             Sentry::createGroup($group);
         } catch (Exception $e) {
             // If we need to stop it, then we could just throw it
             // throw $e;
         }
     }
 }
 /**
  * admin.groups.store
  *
  */
 public function postAdminCreate()
 {
     if (Sentry::hasAnyAccess(['groups_create'])) {
         try {
             $group = Sentry::createGroup(['name' => Input::get('name'), 'permissions' => ['admin' => Input::get('admin'), 'deeds_index' => Input::get('deeds_index'), 'deeds_create' => Input::get('deeds_create'), 'deeds_update' => Input::get('deeds_update'), 'deeds_delete' => Input::get('deeds_delete'), 'agrarians_index' => Input::get('agrarians_index'), 'agrarians_create' => Input::get('agrarians_create'), 'agrarians_update' => Input::get('agrarians_update'), 'agrarians_delete' => Input::get('agrarians_delete'), 'civils_index' => Input::get('civils_index'), 'civils_create' => Input::get('civils_create'), 'civils_update' => Input::get('civils_update'), 'civils_delete' => Input::get('civils_delete'), 'penals_index' => Input::get('penals_index'), 'penals_create' => Input::get('penals_create'), 'penals_update' => Input::get('penals_update'), 'penals_delete' => Input::get('penals_delete'), 'records_index' => Input::get('records_index'), 'records_create' => Input::get('records_create'), 'records_update' => Input::get('records_update'), 'records_delete' => Input::get('records_delete'), 'notaries_index' => Input::get('notaries_index'), 'notaries_create' => Input::get('notaries_create'), 'notaries_update' => Input::get('notaries_update'), 'notaries_delete' => Input::get('notaries_delete'), 'municipalities_index' => Input::get('municipalities_index'), 'municipalities_create' => Input::get('municipalities_create'), 'municipalities_update' => Input::get('municipalities_update'), 'municipalities_delete' => Input::get('municipalities_delete'), 'users_index' => Input::get('users_index'), 'users_create' => Input::get('users_create'), 'users_update' => Input::get('users_update'), 'users_delete' => Input::get('users_delete'), 'groups_index' => Input::get('groups_index'), 'groups_create' => Input::get('groups_create'), 'groups_update' => Input::get('groups_update'), 'groups_delete' => Input::get('groups_delete')]]);
             return Redirect::route('admin.groups.create')->with(['message' => 'Grupo creado con exito', 'class' => 'success']);
         } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
             return Redirect::route('admin.groups.create')->with(['message' => 'El nombre es requerido', 'class' => 'warning']);
         } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
             return Redirect::route('admin.groups.create')->with(['message' => 'El grupo ya existe', 'class' => 'warning']);
         }
     } else {
         return Redirect::route('pages.error');
     }
 }
Ejemplo n.º 21
0
 /**
  * Store a newly created resource in storage.
  * POST /roles
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), array('name' => 'required|max:20|min:2', 'description' => 'max:255'));
     if ($validator->fails()) {
         return Redirect::route('create-roles')->withErrors($validator)->withInput();
     } else {
         try {
             $group = Sentry::createGroup(array('name' => Input::get('name'), 'description' => Input::get('description')));
             if ($group) {
                 return Redirect::route('roles')->with('global', 'A new Role has been created.');
             }
         } catch (\Exception $e) {
             return Redirect::route('create-roles')->with('error', $e->getMessage());
         }
     }
 }
 public function fire()
 {
     try {
         $adminGroup = \Sentry::findGroupByName('admin');
         $password = $this->option('pass') ?: str_random(12);
         $user = \Sentry::createUser(array('email' => $this->argument('email'), 'password' => $password, 'activated' => true, 'permissions' => array('superuser' => '1')));
         $user->addGroup($adminGroup);
         $this->info('pass: '******'pass') ?: str_random(12);
         $user = \Sentry::createUser(array('email' => $this->argument('email'), 'password' => $password, 'activated' => true, 'permissions' => array('superuser' => '1')));
         $adminGroup = \Sentry::createGroup(array('name' => 'admin', 'permissions' => array()));
         $user->addGroup($adminGroup);
         $this->info('pass: ' . $password);
     }
 }
Ejemplo n.º 23
0
 /**
  * Store a newly created group in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Group::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     try {
         // Create the group
         Sentry::createGroup(array('name' => $data['name'], 'permissions' => array('admin' => 0, 'users' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
     return Redirect::route('groups.index');
 }
Ejemplo n.º 24
0
 public function store()
 {
     //
     $rules = array('group' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('admin.group.create')->withError($validator)->withInput();
     } else {
         try {
             $group = Sentry::createGroup(array('name' => Input::get('group'), 'permissions' => Input::get('cb')));
         } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
             return Redirect::back()->with('errorMessage', 'Name field is required');
         } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
             return Redirect::back()->with('errorMessage', 'Group already exists');
         }
         return Redirect::route('admin.group.index')->with("successMessage", "Berhasil menyimpan group ");
     }
 }
Ejemplo n.º 25
0
 public function import($groups)
 {
     $messages = array();
     foreach ($groups as $group) {
         // Unset the ID
         unset($group['id']);
         try {
             // Create the group
             $group = \Sentry::createGroup($group);
             $messages[$group['name']] = true;
         } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) {
             $messages[$group['name']] = false;
         } catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
             $messages[$group['name']] = false;
         }
     }
     return $messages;
 }
Ejemplo n.º 26
0
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         // create grup admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         // create grup sales
         $group = Sentry::createGroup(array('name' => 'salesman', 'permissions' => array('sales' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
     try {
         /*
          ** Admininistrator
          **
          */
         $admin = Sentry::register(array('email' => '*****@*****.**', 'password' => 'admin', 'first_name' => 'Super', 'last_name' => 'Administrator'), true);
         $adminGroup = Sentry::findGroupByName('admin');
         // Masukkan user ke grup admin
         $admin->addGroup($adminGroup);
         /*
          ** Salesman
          **
          */
         $user = Sentry::register(array('email' => '*****@*****.**', 'password' => 'salesman', 'first_name' => 'Yefta', 'last_name' => 'Aditya Wibowo'), true);
         // Cari grup salesman
         $salesmanGroup = Sentry::findGroupByName('salesman');
         // Masukkan user ke grup salesman
         $user->addGroup($salesmanGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo 'Password field is required.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo 'User with this login already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
 }
Ejemplo n.º 27
0
 /**
  * Create a new Group
  *
  * @usage createGroup('admin','admin');
  *
  * @return bool
  */
 public function createGroup($name, $permission = 'viewer')
 {
     $addPermission = $this->viewer;
     // Set permission level
     switch ($permission) {
         case "god":
             $addPermission = $this->god;
             break;
         case "superadmin":
             $addPermission = $this->superadmin;
             break;
         case "admin":
             $addPermission = $this->admin;
             break;
         case "financeadmin":
             $addPermission = $this->financeadmin;
             break;
         case "financeeditor":
             $addPermission = $this->financeeditor;
             break;
         case "financeviewer":
             $addPermission = $this->financeviewer;
             break;
         case "editor":
             $addPermission = $this->editor;
             break;
         case "viewer":
             $addPermission = $this->viewer;
             break;
     }
     try {
         // Create the group
         $group = Sentry::createGroup(array('name' => $name, 'permissions' => $addPermission));
         if ($group) {
             return true;
         }
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
 }
Ejemplo n.º 28
0
 /**
  * Jalankan database seeder
  *
  * @return void
  */
 public function run()
 {
     //Hapus isi table users, group, user_groups dan throttle
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         // Membuat grup admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         // Membuat grup reguler
         $group = Sentry::createGroup(array('name' => 'user', 'permissions' => array('user' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Gourps\GroupExistsException $e) {
         echo 'Groups already exists';
     }
     try {
         // Membuat admin baru
         $admin = Sentry::register(array('email' => '*****@*****.**', 'password' => 'anchuz2015', 'first_name' => 'Aan Choesni', 'last_name' => 'Herlingga'), true);
         // langsung diaktivasi
         // Cari grup admin
         $adminGroup = Sentry::findGroupByName('admin');
         // Masukkan user ke grup admin
         $admin->addGroup($adminGroup);
         // Membuat user regular baru
         $user = Sentry::register(array('email' => '*****@*****.**', 'password' => 'inseo2015', 'first_name' => 'Nofida', 'last_name' => 'Suwitasari'), true);
         // Cari grup regular
         $regularGroup = Sentry::findGroupByName('user');
         // Masukkan user ke grup regular
         $user->addGroup($regularGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo 'Password field is reuired.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo 'User with this login aready exists.';
     } catch (Cartalyst\Sentry\User\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
 }
Ejemplo n.º 29
0
 /**
  * Jalankan database seeder
  *
  * @return void
  */
 public function run()
 {
     //Hapus isi table users, group, user_groups dan throttle
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         // Membuat grup admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         // Membuat grup reguler
         $group = Sentry::createGroup(array('name' => 'regular', 'permissions' => array('reguler' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Gourps\GroupExistsException $e) {
         echo 'Groups already exists';
     }
     try {
         // Membuat admin baru
         $admin = Sentry::register(array('email' => '*****@*****.**', 'password' => 'adminfmipa2015', 'first_name' => 'Admin Surat', 'last_name' => 'FMIPA'), true);
         // langsung diaktivasi
         // Cari grup admin
         $adminGroup = Sentry::findGroupByName('admin');
         // Masukkan user ke grup admin
         $admin->addGroup($adminGroup);
         // Membuat user regular baru
         $user = Sentry::register(array('email' => '*****@*****.**', 'password' => 'mahsiswafmipa', 'first_name' => 'Mahasiswa', 'last_name' => 'FMIPA'), true);
         // Cari grup regular
         $regularGroup = Sentry::findGroupByName('regular');
         // Masukkan user ke grup regular
         $user->addGroup($regularGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo 'Password field is reuired.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo 'User with this login aready exists.';
     } catch (Cartalyst\Sentry\User\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
 }
 public function store()
 {
     $inputs = [];
     foreach (Input::all() as $key => $input) {
         if ($key == 'password' || $key == 'password_confirmation') {
             $inputs[$key] = $input;
         } else {
             $inputs[$key] = Jamesy\Sanitiser::trimInput($input);
         }
     }
     $validation = Jamesy\MyValidations::validate($inputs, array_merge(Setting::$rules, User::$rules));
     if ($validation != NULL) {
         return Response::json($validation);
     } else {
         $setup = new Setting();
         $setup->sitename = Input::get('sitename');
         $setup->save();
         $maillist = new Maillist();
         $maillist->name = "General";
         $maillist->save();
         $tag = new Tag();
         $tag->name = "Test Emails";
         $tag->save();
         try {
             $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password_confirmation'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true);
             $group = Sentry::createGroup(['name' => 'Administrator']);
             $group = Sentry::createGroup(['name' => 'Publisher']);
             $group = Sentry::findGroupByName('Administrator');
             $user->addGroup($group);
             return Response::json(["success" => "It's all ready! You are being redirected to the login page...", "url" => URL::to('dashboard/login')]);
         } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
             return Response::json(["email" => "Email is required."]);
         } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
             return Response::json(["password" => "Password is required."]);
         } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
             return Response::json(["email" => "Email is already taken."]);
         }
     }
 }