本文整理汇总了PHP中Sentry::findGroupByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findGroupByName方法的具体用法?PHP Sentry::findGroupByName怎么用?PHP Sentry::findGroupByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::findGroupByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
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' => 'alanpachuau@gmail.com', 'name' => 'Alan Pachuau', 'password' => 'pass', 'activated' => 1, 'permissions' => ['superuser' => 1]]);
// Create the super user
$user = Sentry::createUser(['email' => 'remasailo@gmail.com', 'name' => 'Rema Sailo', 'password' => 'pass', 'activated' => 1, 'permissions' => ['superuser' => 1]]);
$user = Sentry::createUser(['email' => 'larislhmar@gmail.com', 'name' => 'Lalrinsanga', 'password' => 'pass', 'activated' => 1, 'permissions' => ['superuser' => 1]]);
$user = Sentry::createUser(['email' => 'manager@mail.com', 'name' => 'Manager', 'password' => 'pass', 'activated' => 1, 'permissions' => []]);
$user->addGroup($manager);
$user = Sentry::createUser(['email' => 'storemanager@gmail.com', 'name' => 'Store Manager', 'password' => 'pass', 'outlet_id' => 1, 'activated' => 1, 'permissions' => []]);
$user->addGroup($storeManager);
$user = Sentry::createUser(['email' => 'salesperson@gmail.com', 'name' => 'Sales Person', 'password' => 'pass', 'outlet_id' => 1, 'activated' => 1, 'permissions' => []]);
$user->addGroup($salesPerson);
$user = Sentry::createUser(['email' => 'salesperson2@gmail.com', 'name' => 'Sales Person2', 'password' => 'pass', 'outlet_id' => 2, 'activated' => 1, 'permissions' => []]);
$user->addGroup($salesPerson);
$user = Sentry::createUser(['email' => 'salesperson3@gmail.com', 'name' => 'Sales Person3', 'password' => 'pass', 'outlet_id' => 3, 'activated' => 1, 'permissions' => []]);
$user->addGroup($salesPerson);
$user = Sentry::createUser(['email' => 'salesperson4@gmail.com', 'name' => 'Sales Person4', 'password' => 'pass', 'outlet_id' => 4, 'activated' => 1, 'permissions' => []]);
$user->addGroup($salesPerson);
$user = Sentry::createUser(['email' => 'salesperson5@gmail.com', 'name' => 'Sales Person5', 'password' => 'pass', 'outlet_id' => 5, 'activated' => 1, 'permissions' => []]);
$user->addGroup($salesPerson);
}
示例2: run
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: run
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' => 'admin@mail.com', 'password' => 'admin', 'first_name' => 'Administrator', 'last_name' => 'IT KSA'), true);
$adminGroup = Sentry::findGroupByName('administrator');
$admin->addGroup($adminGroup);
$operator = Sentry::register(array('email' => 'antoniosaiful10@gmail.com', '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: edit
/**
* 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: store
/**
* 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: postAdminAccount
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: store
/**
* 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: change
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: store
/**
* 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: run
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: createUser
/**
* 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: getGraphData
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: POST_assignGroup
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: import
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: run
public function run()
{
// Refresh Brand_user_groups
DB::table('group_user_brand')->truncate();
$entries = array(array('user_id' => Sentry::findUserByLogin('superuser@saasventure.com')->id, 'group_id' => Sentry::findGroupByName('Admin')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('BizGym')->id), array('user_id' => Sentry::findUserByLogin('foo@saasventure.com')->id, 'group_id' => Sentry::findGroupByName('User')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('SaaS Venture Group')->id), array('user_id' => Sentry::findUserByLogin('rob@bertholf.com')->id, 'group_id' => Sentry::findGroupByName('Admin')->id, 'brand_id' => Groups::getBrandProvider()->findByTitle('BizGym')->id), array('user_id' => Sentry::findUserByLogin('rob@bertholf.com')->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);
}