コード例 #1
0
 public function run()
 {
     $manager = Sentry::findGroupByName('Manager');
     $storeManager = Sentry::findGroupByName('Store Manager');
     $salesPerson = Sentry::findGroupByName('Sales Person');
     // Create the super user
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Alan Pachuau', 'password' => 'pass', 'activated' => 1, 'permissions' => ['superuser' => 1]]);
     // Create the super user
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Rema Sailo', 'password' => 'pass', 'activated' => 1, 'permissions' => ['superuser' => 1]]);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Lalrinsanga', 'password' => 'pass', 'activated' => 1, 'permissions' => ['superuser' => 1]]);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Manager', 'password' => 'pass', 'activated' => 1, 'permissions' => []]);
     $user->addGroup($manager);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Store Manager', 'password' => 'pass', 'outlet_id' => 1, 'activated' => 1, 'permissions' => []]);
     $user->addGroup($storeManager);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Sales Person', 'password' => 'pass', 'outlet_id' => 1, 'activated' => 1, 'permissions' => []]);
     $user->addGroup($salesPerson);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Sales Person2', 'password' => 'pass', 'outlet_id' => 2, 'activated' => 1, 'permissions' => []]);
     $user->addGroup($salesPerson);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Sales Person3', 'password' => 'pass', 'outlet_id' => 3, 'activated' => 1, 'permissions' => []]);
     $user->addGroup($salesPerson);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Sales Person4', 'password' => 'pass', 'outlet_id' => 4, 'activated' => 1, 'permissions' => []]);
     $user->addGroup($salesPerson);
     $user = Sentry::createUser(['email' => '*****@*****.**', 'name' => 'Sales Person5', 'password' => 'pass', 'outlet_id' => 5, 'activated' => 1, 'permissions' => []]);
     $user->addGroup($salesPerson);
 }
コード例 #2
0
ファイル: SentrySeeder.php プロジェクト: jamalapriadi/sia
 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";
     }
 }
コード例 #3
0
 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";
     }
 }
コード例 #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data = $this->project->find($id);
     $group = Sentry::findGroupByName('Project Manager');
     $users = Sentry::findAllUsersInGroup($group);
     return View::make('projects.edit')->with('projects', $data)->with('users', $users);
 }
コード例 #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $this->loginForm->validate($input = Input::only('email', 'password'));
     try {
         Sentry::authenticate($input, true);
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.mgs_invalid_credential'), 'url' => '');
         return Response::json($mjs);
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.user_not_activated'), 'url' => '');
         return Response::json($mjs);
     } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.user_suspended'), 'url' => '');
         return Response::json($mjs);
     }
     // Logged in successfully - redirect based on type of user
     $user = Sentry::getUser();
     $admin = Sentry::findGroupByName('Admins');
     $users = Sentry::findGroupByName('Patients');
     $doctors = Sentry::findGroupByName('Doctors');
     $company = Sentry::findGroupByName('Clinics');
     $recepcion = Sentry::findGroupByName('Receptionist');
     if ($user->inGroup($admin)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/admin');
         return Response::json($mjs);
     } elseif ($user->inGroup($company) or $user->inGroup($recepcion)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/clinic');
         return Response::json($mjs);
     } elseif ($user->inGroup($doctors)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/doctor');
         return Response::json($mjs);
     } elseif ($user->inGroup($users)) {
         return Redirect::to(url());
     }
 }
コード例 #6
0
ファイル: InstallController.php プロジェクト: ymnl007/92five
 public function postAdminAccount()
 {
     $data = Input::all();
     //return View::make('install.done');
     try {
         $user = Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'activated' => true, 'first_name' => $data['first_name'], 'last_name' => $data['last_name']));
         $group = Sentry::findGroupByName('admin');
         $user->addGroup($group);
         $quicknote = new \Quicknote();
         $quicknote->user_id = $user->id;
         $quicknote->save();
         $userProfile = new \UserProfile();
         $userProfile->id = $user->id;
         $userProfile->save();
         $imageResult = App::make('AuthController')->{'createUserImage'}($user->id, $data['first_name'][0], $data['last_name'][0]);
         $installationDate = date('Y-m-d H:i:s');
         $installationHost = Request::server('PATH_INFO');
         $new92fiveConfig = new NewConfig();
         $new92fiveConfig->toFile(app_path() . '/config/92five.php', ['install' => true, 'version' => '1.0', 'installationDate' => $installationDate, 'installationHost' => $installationHost]);
         return View::make('install.done');
     } catch (Exception $e) {
         Log::error('Something Went Wrong in Install Controller Repository - addUserWithDetails():' . $e->getMessage());
         throw new Exception('Something Went Wrong in Install Controller Repository - addUserWithDetails()');
     }
 }
コード例 #7
0
 /**
  * Store a newly created resource in storage.
  * POST /sessions/store.
  *
  * @return Response
  */
 public function store()
 {
     // Set login credentials
     $input = array('email' => Input::get('email'), 'password' => Input::get('password'));
     // Try to authenticate the user
     try {
         Sentry::authenticate($input, Input::has('remember'));
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->withInput()->withErrorMessage('Invalid credentials provided');
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Redirect::back()->withInput()->withErrorMessage('User Not Activated.');
     }
     // Logged in successfully - redirect based on type of user
     $user = Sentry::getUser();
     $adminsGroup = Sentry::findGroupByName('Admins');
     $usersGroup = Sentry::findGroupByName('Users');
     if ($user->inGroup($adminsGroup)) {
         return Redirect::intended('admin');
     } elseif ($user->inGroup($usersGroup)) {
         if (!stripos(Session::get('url.intended', '/'), '/admin')) {
             return Redirect::intended('/');
         } else {
             return Redirect::to('/');
         }
     }
 }
コード例 #8
0
ファイル: AdminController.php プロジェクト: eldalo/jarvix
 public function change()
 {
     if (Request::isMethod('post')) {
         try {
             $rules = Validator::make(Input::all(), ['password' => 'required|confirmed', 'password_confirmation' => 'required']);
             if ($rules->fails()) {
                 throw new Exception('Todos los campos son obligatorios');
             }
             $data = explode('@', Input::get('data'));
             $id = base64_decode($data[1]);
             $user = Sentry::findUserById($id);
             $admin = Sentry::findGroupByName('Administrador');
             if (!$user->checkResetPasswordCode($data[0])) {
                 throw new Exception('El código de chequeo no es correcto.');
             }
             if (!$user->attemptResetPassword($data[0], Input::get('password_confirmation'))) {
                 throw new Exception('Se presento un error al guardar la nueva contraseña.');
             }
             if (!$user->inGroup($admin) || !$user->isActivated()) {
                 throw new Exception('Este usuario no tiene permisos para ingresar o esta inactivo.');
             }
             Sentry::login($user);
             return Redirect::route('admin.dashboard');
         } catch (Exception $e) {
             $uri = URL::route('admin.forgot-reset', [Input::get('data')]);
             return Redirect::to($uri)->with('message', $e->getMessage());
         }
     }
 }
コード例 #9
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $date = \Carbon\Carbon::now();
     $validator = Validator::make($data = Input::all(), User::$rules);
     $validatora = Validator::make($dataa = Input::all(), Registrasi::$rules);
     if ($validatora->fails()) {
         return Redirect::back()->withErrors($validatora)->withInput();
     } else {
         if ($validator->fails()) {
             return Redirect::back()->withErrors($validator)->withInput();
         } else {
             // Register User tanpa diaktivasi
             $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('name'), 'last_name' => Input::get('jenjang')), false);
             // Cari grup user
             $regularGroup = Sentry::findGroupByName('user');
             // Masukkan user ke grup user
             $user->addGroup($regularGroup);
             DB::table('schools')->insertGetId(array('jenjang' => input::get('jenjang'), 'name' => Input::get('name'), 'adstreet' => Input::get('adstreet'), 'advillage' => Input::get('advillage'), 'addistricts' => Input::get('addistricts'), 'adcity' => Input::get('adcity'), 'adpostalcode' => Input::get('adpostalcode'), 'adphone' => Input::get('adphone'), 'hmname' => Input::get('hmname'), 'hmphone' => Input::get('hmphone'), 'hmmobile' => Input::get('hmphone'), 'user_id' => $user->id, 'created_at' => $date, 'updated_at' => $date));
             // Persiapkan activation code untuk dikirim ke email
             $data = ['email' => $user->email, 'activationCode' => $user->getActivationCode()];
             // Kirim email aktivasi
             Mail::send('emails.auth.register', $data, function ($message) use($user) {
                 $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Aktivasi Akun SIM Atletik UNESA');
             });
             // Redirect ke halaman login
             return Redirect::route('login')->with("successMessage", "Berhasil disimpan. Silahkan cek email ({$user->email}) untuk melakukan aktivasi akun.");
         }
     }
 }
コード例 #10
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.';
     }
 }
コード例 #11
0
ファイル: ManageController.php プロジェクト: shampine/plumage
 /**
  * Handles POST requests for /manage/create
  *
  * @return redirect
  */
 public function createUser()
 {
     $newUser = Sentry::createUser(['email' => $this->input['email'], 'password' => $this->input['password'], 'activated' => true]);
     $group = Sentry::findGroupByName($this->input['group']);
     $newUser->addGroup($group);
     return Redirect::back()->with(['error' => false, 'message' => 'User created successfully.']);
 }
コード例 #12
0
 public function getGraphData()
 {
     if (Sentry::getUser()) {
         $user_id = Sentry::getUser()->id;
         $period = Input::get('check_report_period');
         $mongo_id = Input::get('report_mongo_id');
         $check_id = Input::get('report_check_id');
         $mongoAPI = new MongoAPI();
         $checkAlertEmail = new CheckAlertEmail();
         $data = json_decode($mongoAPI->getServerModelData($mongo_id, $period), true);
         $data['alert'] = $checkAlertEmail->getDataByCheckId($check_id);
         return Response::json($data);
     } else {
         try {
             $user = Sentry::findUserById(Input::get('user_id'));
             $emf_group = Sentry::findGroupByName('EmfUsers');
             if ($user->inGroup($emf_group)) {
                 return $this->get_exired_message(Config::get('kuu.emf_login_page'));
             } else {
                 return $this->get_exired_message(URL::route('login'));
             }
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return $this->get_exired_message(URL::route('login'));
         } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
             return $this->get_exired_message(URL::route('login'));
         }
     }
 }
コード例 #13
0
 public function POST_assignGroup($params)
 {
     $ex_params = explode('_', $params);
     $group_name = ucfirst($ex_params[0]);
     $route = $ex_params[1];
     $action = $ex_params[2];
     $group = Sentry::findGroupByName($group_name);
     $permits = $group->permissions;
     if ($action == 'push') {
         $permits[$route] = 1;
         $msg = 'Route `' . $route . '` successfully added to group `' . $group_name . '`';
     } else {
         if ($action == 'pop') {
             $permits[$route] = 0;
             $msg = 'Route `' . $route . '` successfully removed from group `' . $group_name . '`';
         } else {
             return Redirect::to(route('group.assign'));
         }
     }
     $group->permissions = $permits;
     if ($group->save()) {
         return Redirect::to(route('group.assign', '#' . $route))->with('STATUS_OK', $msg);
     } else {
         return Redirect::to(route('group.assign', '#' . $route))->with('STATUS_FAIL', $msg);
     }
 }
コード例 #14
0
ファイル: Users.php プロジェクト: jalbertbowden/core
 public function import($users)
 {
     $messages = array();
     foreach ($users as $user) {
         $groups = $user['groups'];
         $primary_group = array_shift($groups);
         // Unset the unnecessary fields
         unset($user['id']);
         unset($user['groups']);
         try {
             // Create the user
             $created_user = \Sentry::createUser($user);
             // Manually update password
             \DB::table('users')->where('id', $created_user->id)->update(array('password' => $user['password']));
             // Try adding user to groups
             try {
                 // Find the group using the group name
                 $group = \Sentry::findGroupByName($primary_group);
                 // Assign the group to the user
                 $created_user->addGroup($group);
             } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
                 echo "Group '{$primary_group}' was not found.";
             }
             $messages[$user['email']] = true;
         } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) {
             $messages[$user['email']] = false;
         } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) {
             $messages[$user['email']] = false;
         } catch (\Cartalyst\Sentry\Users\UserExistsException $e) {
             $messages[$user['email']] = false;
         }
     }
     return $messages;
 }
コード例 #15
0
 public function run()
 {
     // Refresh Brand_user_groups
     DB::table('group_user_brand')->truncate();
     $entries = array(array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('Admin')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('BizGym')->id), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('User')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('SaaS Venture Group')->id), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('Admin')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('BizGym')->id), array('user_id' => Sentry::findUserByLogin('*****@*****.**')->id, 'group_id' => Sentry::findGroupByName('User')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('SaaS Venture Group')->id));
     // Uncomment the below to run the seeder
     DB::table('group_user_brand')->insert($entries);
 }
コード例 #16
0
 public function dashboard()
 {
     $user = Sentry::getUser();
     $admin = Sentry::findGroupByName('admin');
     //Admin
     if ($user->inGroup($admin)) {
         return View::make('dashboard.index')->withTitle('Dashboard')->with('successMessage', 'Anda Berhasil logout.');
     }
 }
コード例 #17
0
 public function postAdmin()
 {
     $email = preg_replace('/\\s+/', '', Input::get('email'));
     $password = preg_replace('/\\s+/', '', Input::get('password'));
     $validation = array('email' => 'required|email', 'password' => 'required|min:6');
     $messages = array('password.required' => 'The password is required.', 'password.min' => 'The password must be at least 6 characters(No spaces allowed).');
     $validator = Validator::make(array('email' => $email, 'password' => $password), $validation, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withInput(Input::except('password'))->withErrors($validator);
     }
     try {
         $user = Sentry::createUser(array('email' => $email, 'password' => $password, 'activated' => true));
         // Find the group using the group id
         $admin_group = Sentry::findGroupByName('Administrator');
         // Assign the group to the user
         $user->addGroup($admin_group);
         //            return Redirect::to('install/complete');
         $credentials = array('email' => $email, 'password' => $password);
         // Authenticate the user
         $auth = Sentry::authenticate($credentials, false);
         $data = array('track' => 2);
         $write = $this->track_obj->writeTrack($data);
         if ($write) {
             Log::info('Installation track wrote successfully');
         } else {
             Log::error('Failed to write installation track');
         }
         //            TrackReq::get()->send_track($_SERVER['REQUEST_URI']);
         $ret = TrackReq::get()->sendTrack(Request::server('SERVER_NAME') . $_SERVER['REQUEST_URI']);
         if ($ret[0]) {
             Log::info('Installed successfully');
         } else {
             Log::error('Installation failed', ['context' => $ret[1]]);
         }
         return Redirect::to('setting');
         //            return Redirect::to('login/login/1');
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Redirect::back()->withInput(Input::except('password'))->with('msg', 'Login field is required');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Redirect::back()->withInput(Input::except('password'))->with('msg', 'Password field is required.');
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         return Redirect::back()->withInput(Input::except('password'))->with('msg', 'User with this login already exists.');
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         return Redirect::back()->withInput(Input::except('password'))->with('msg', 'Group was not found.');
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Redirect::back()->withInput()->with('msg', 'Wrong password, try again.');
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->withInput()->with('msg', 'User was not found.');
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Redirect::back()->withInput()->with('msg', 'User is not activated.');
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         return Redirect::back()->withInput()->with('msg', 'User is suspended.');
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Redirect::back()->withInput()->with('msg', 'User is banned.');
     }
 }
コード例 #18
0
 public function testRetrieveGroupById()
 {
     // Find the group we will use for reference
     $reference = Sentry::findGroupByName('Users');
     // This is the code we are testing
     $group = $this->repo->retrieveById($reference->id);
     // Assertions
     $this->assertInstanceOf('Sentinel\\Models\\Group', $group);
     $this->assertEquals('Users', $group->name);
 }
コード例 #19
0
 public function create()
 {
     //
     try {
         $bqu_group = Sentry::findGroupByName('BQu');
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
     $supervisors = DB::table('users')->join('users_groups', 'users.id', '=', 'users_groups.user_id')->select('users.id', 'users.first_name', 'users.last_name')->get();
     return View::make('students.create')->with('information_sources', ApplicationSource::lists('name', 'id'))->with('admission_managers', ApplicationAdmissionManager::lists('name', 'id'))->with('agents_laps', array_merge(ApplicationAgent::lists('name', 'id'), ApplicationLap::lists('name', 'id')))->with('nationalities', StaticNationality::lists('name', 'id'))->with('countries', StaticCountry::lists('name', 'id'))->with('course_names', ApplicationCourse::lists('name', 'id'))->with('awarding_bodies', ApplicationAwardingBody::lists('name', 'id'))->with('education_qualifications', ApplicationEducationalQualification::lists('name', 'id'))->with('method_of_payment', ApplicationPaymentInfoMethodsOfPayment::lists('name', 'id'))->with('application_status', ApplicationStatus::lists('name', 'id'))->with('intake_year', StaticYear::lists('name', 'id'))->with('intake', ApplicationIntake::where('year', '=', 1)->lists('name', 'id'))->with('supervisors', $supervisors);
 }
コード例 #20
0
ファイル: User.php プロジェクト: shinichi81/Nifty-Newsletter
 public static function isPublisher($user)
 {
     $isPublisher = false;
     if ($user) {
         $publisher = Sentry::findGroupByName('Publisher');
         if ($user->inGroup($publisher)) {
             $isPublisher = true;
         }
     }
     return $isPublisher;
 }
コード例 #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(RegistrationFormRequest $request)
 {
     $input = $request->only('email', 'password', 'first_name', 'last_name');
     $input = array_add($input, 'activated', true);
     $user = $this->user->create($input);
     // Find the group using the group name
     $usersGroup = \Sentry::findGroupByName('Users');
     // Assign the group to the user
     $user->addGroup($usersGroup);
     return redirect('login')->withFlashMessage('User Successfully Created!');
 }
コード例 #22
0
 public function postUlogin()
 {
     $_user = json_decode(file_get_contents('http://ulogin.ru/token.php?token=' . Input::get('token') . '&host=' . $_SERVER['HTTP_HOST']), true);
     //$user['network'] - соц. сеть, через которую авторизовался пользователь
     //$user['identity'] - уникальная строка определяющая конкретного пользователя соц. сети
     //$user['first_name'] - имя пользователя
     //$user['last_name'] - фамилия пользователя
     $validate = Validator::make([], []);
     if (isset($_user['error'])) {
         $validate->errors()->add('error', trans('larulogin::larulogin.' . $_user['error']));
         return Response::make(View::make(Config::get('larulogin::views.error'), ['errors' => $validate->errors()]), 401);
     }
     // Check exist user
     $check = Ulogin::where('identity', '=', $_user['identity'])->first();
     if ($check) {
         Auth::loginUsingId($check->user_id, true);
         if (class_exists('Sentry')) {
             $authSentry = Sentry::findUserById($check->user_id);
             Sentry::login($authSentry, true);
         }
         return Redirect::to('/');
     }
     $rules = array('network' => 'required|max:255', 'identity' => 'required|max:255|unique:ulogin', 'email' => 'required|unique:ulogin|unique:users');
     $messages = array('email.unique' => trans('larulogin::larulogin.email_already_registered'));
     $validate = Validator::make($_user, $rules, $messages);
     if ($validate->passes()) {
         $password = str_random(8);
         $user = Sentry::createUser(array('first_name' => $_user['first_name'], 'last_name' => $_user['last_name'], 'email' => $_user['email'], 'password' => $password, 'activated' => TRUE));
         foreach (Config::get('larulogin::add_to_groups') as $group_name) {
             $user->addGroup(Sentry::findGroupByName($group_name));
         }
         $ulogin = new Ulogin();
         $ulogin->user_id = $user->id;
         $ulogin->network = $_user['network'];
         $ulogin->identity = $_user['identity'];
         $ulogin->email = $_user['email'];
         $ulogin->first_name = $_user['first_name'];
         $ulogin->last_name = $_user['last_name'];
         $ulogin->photo = $_user['photo'];
         $ulogin->photo_big = $_user['photo_big'];
         $ulogin->profile = $_user['profile'];
         $ulogin->access_token = isset($_user['access_token']) ? $_user['access_token'] : '';
         $ulogin->country = isset($_user['country']) ? $_user['country'] : '';
         $ulogin->city = isset($_user['city']) ? $_user['city'] : '';
         $ulogin->save();
         $authClassic = Auth::loginUsingId($user->id);
         if (class_exists('Sentry')) {
             $authSentry = Sentry::authenticate(array('email' => $_user['email'], 'password' => $password), true);
         }
         return Redirect::to('/');
     } else {
         return Response::make(View::make(Config::get('larulogin::views.error'), array('errors' => $validate->errors())), 401);
     }
 }
コード例 #23
0
 public function destroy($id)
 {
     $lead = Lead::find($id);
     $user = Sentry::getUser();
     $salesman = Sentry::findGroupByName('salesman');
     if ($user->inGroup($salesman) && $lead->users != $user->id) {
         return Response::json(array('flash' => 'ERROR 403 : You are prohibited to remove this lead !'), 403);
     } else {
         $lead->users()->detach();
         $lead->delete();
         return Response::json(array('success' => true, 'flash' => 'The lead has successfully removed !'), 200);
     }
 }
コード例 #24
0
 public function postRegister()
 {
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users,email,:id', 'password' => 'required', 'password_confirmation' => 'required|same:password');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput(Input::except('password', 'password_confirm'));
     } else {
         $user = Sentry::register(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'password' => Input::get('password')), false);
         $userGroup = Sentry::findGroupByName('user');
         $user->addGroup($userGroup);
         return View::make('dashboard.guest.registermessage');
     }
 }
コード例 #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::only('email', 'password', 'password_confirmation', 'first_name', 'last_name');
     $this->registrationForm->validate($input);
     $input = Input::only('email', 'password', 'first_name', 'last_name');
     $input = array_add($input, 'activated', true);
     $user = $this->user->create($input);
     // Find the group using the group name
     $usersGroup = Sentry::findGroupByName('Users');
     // Assign the group to the user
     $user->addGroup($usersGroup);
     return Redirect::to('login')->withFlashMessage('User Successfully Created!');
 }
コード例 #26
0
ファイル: User.php プロジェクト: amcfarlane1251/lcnsMgmt
 /**
  * Returns array of strings of groups a user belongs.
  *
  * @return array
  */
 public function group()
 {
     $groups = array();
     $groups[] = Sentry::findGroupByName('Authorizers');
     $groups[] = Sentry::findGroupByName('Admin');
     $return = array();
     foreach ($groups as $group) {
         if ($this->inGroup($group)) {
             $return[] = $group->name;
         }
     }
     return $return;
 }
コード例 #27
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //DB::table('users')->delete();
     $user = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => 'KuuAdmin', 'activated' => 1));
     $adminGroup = Sentry::findGroupByName('Admins');
     $user->addGroup($adminGroup);
     /*
     	    Sentry::getUserProvider()->create(array(
     	        'email'    => '*****@*****.**',
     	        'password' => 'sentryuser',
     	        'activated' => 1,
     	    ));
     */
 }
コード例 #28
0
ファイル: UserTableSeeder.php プロジェクト: shampine/plumage
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Groups
     $admin = Sentry::findGroupByName('admin');
     $user = Sentry::findGroupByName('user');
     // Creates our sole admin user
     $createAdmin = Sentry::createUser(['first_name' => 'Marty', 'last_name' => 'McFly', 'email' => '*****@*****.**', 'password' => 'password', 'activated' => true]);
     $createAdmin->addGroup($admin);
     // Creates a set of random non admin users
     for ($i = 1; $i <= $this->seed; $i++) {
         $createUser = Sentry::createUser(['first_name' => $this->faker->firstName, 'last_name' => $this->faker->lastName, 'email' => $this->faker->email, 'password' => 'password', 'activated' => true]);
         $createUser->addGroup($user);
     }
 }
コード例 #29
0
 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);
     }
 }
コード例 #30
0
 /**
  * Create root user and basic permission structure in the database.
  * For detailed documentation on permission structure, see
  * PermissionHandler class.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // Create admin user with admin permisions
     Sentry::getUserProvider()->create(['_id' => ProjectHandler::ADMIN_USER, 'password' => 'admin', 'email' => '*****@*****.**', 'firstname' => 'Admin', 'lastname' => 'Crowdtruth']);
     // Create the admin group with special permission Permissions::ALLOW_ALL
     ProjectHandler::createGroup('admin');
     $adminGroup = Sentry::findGroupByName('admin:admin');
     $permissions = $adminGroup->permissions;
     $permissions[Permissions::ALLOW_ALL] = 1;
     // Allowed everything !
     $adminGroup->permissions = $permissions;
     $adminGroup->save();
     // Assign user admin to group admin.
     $root = Sentry::findUserByLogin(ProjectHandler::ADMIN_USER);
     $root->addGroup($adminGroup);
 }