当前位置: 首页>>代码示例>>PHP>>正文


PHP Sentry::createUser方法代码示例

本文整理汇总了PHP中Sentry::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::createUser方法的具体用法?PHP Sentry::createUser怎么用?PHP Sentry::createUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentry的用法示例。


在下文中一共展示了Sentry::createUser方法的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);
 }
开发者ID:nurulimamnotes,项目名称:point-of-sale,代码行数:25,代码来源:UserTableSeeder.php

示例2: save

 public function save()
 {
     if (Request::ajax() && Request::isMethod('post')) {
         try {
             $input = Input::all();
             $valid = Validator::make($input, ['username' => 'required', 'email' => 'required|email', 'full_name' => 'required']);
             if ($valid->fails()) {
                 throw new Exception('Todos los campos son obligatorios');
             }
             if (empty($input['id'])) {
                 $group = Sentry::findGroupById($input['group']);
                 $user = Sentry::createUser(['username' => $input['username'], 'email' => $input['email'], 'full_name' => $input['full_name'], 'password' => $input['password_confirmation'], 'activated' => !empty($input['activated']) ? 1 : 0]);
                 $user->addGroup($group);
             } else {
                 $user = Sentry::findUserById($input['id']);
                 $user->email = $input['email'];
                 $user->full_name = $input['full_name'];
                 $user->activated = !empty($input['activated']) ? 1 : 0;
                 $user->save();
             }
             return Response::json(URL::route('admin.users'), 200);
         } catch (Exception $e) {
             return Response::json($e->getMessage(), 400);
         }
     }
 }
开发者ID:eldalo,项目名称:jarvix,代码行数:26,代码来源:UsersController.php

示例3: createStudent

 public function createStudent()
 {
     $vld_result = FALSE;
     $user_id = $this->generateResourceId("SYN", 20);
     $regDetails = array("first_name" => Synergixe\StrRoutines::sanitize_input(Input::get('first_name'), Synergixe\StrRoutines::FILTER_SPECIAL_STR), "last_name" => Synergixe\StrRoutines::sanitize_input(Input::get('last_name'), Synergixe\StrRoutines::FILTER_SPECIAL_STR), "mobile_phone" => Synergixe\StrRoutines::sanitize_input(Input::get('mobile_phone'), Synergixe\StrRoutines::FILTER_DIGIT_STR), "sex" => Synergixe\StrRoutines::sanitize_input(Input::get('sex'), Synergixe\StrRoutines::FILTER_AS_ENUM, array('male', 'female')), "email" => Synergixe\StrRoutines::sanitize_input(Input::get('email'), Synergixe\StrRoutines::FILTER_AS_EMAIL), "password" => Synergixe\StrRoutines::sanitize_input(Input::get('password'), Synergixe\StrRoutines::FILTER_SPECIAL_STR), "pic_url" => Synergixe\StrRoutines::sanitize_input(Input::get('pic_url'), Synergixe\StrRoutines::FILTER_AS_URL));
     // validate form input values...
     Synergixe\Services\Validation\PostDataValidator::resetRules(array('first_name' => 'required', 'last_name' => 'required', 'mobile_phone' => 'required', 'pic_url' => 'required', 'email' => 'required|email|unique:tbl_synuser', 'password' => 'required|min:6', 'password_confirm' => 'required|same:password'));
     $validator = new Synergixe\Services\Validation\PostDataValidator($regDetails);
     try {
         $vld_result = $validator->passes();
     } catch (Exception $ex) {
         $vld_error = $ex->getMessage();
         Log::error('Validator Internal Error: ' . $vld_error);
         // for debugging purposes...
     }
     if ($vld_result) {
         $user = Sentry::createUser(array_merge($regDetails, array("id" => $user_id)));
         DB::table('tbl_synstudent')->insert(array('student_id' => $user->id, 'badge_limit' => 5));
         /*
         			$code = $user->getActivationCode();
         // send a mail to the newly created user... REM: @okey, the view (email.activation) doesn't exist yet, so, perhaps you can create it (using tables cos most email client don't render CSS floats well and CSS will have to internally defined) -- just something basic, nothing fancy!
         			// @chris, can you properly enable mail functionality (configs e.t.c) for SynAccounts ? If yes, pls do!
         Mail::send('emails.activation', array('key'=>'value') , function($message){
         			    //$message->from('');
         			    $message->to($user->email, $user->last_name.' '.$user->first_name)->subject('Congratulations! Please activate your Synergixe account');
         			});
         */
         // @chris, these are just placeholders for the time being...
         return '<h1>Registration Completed!</h1>';
     }
     // @chris, these are just placeholders for the time being...
     return '<h1>Registration Failed!</h1>';
 }
开发者ID:synergixe,项目名称:SynAccounts,代码行数:33,代码来源:RegisterController.php

示例4: 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;
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:34,代码来源:Users.php

示例5: store

 /**
  * Store a newly created user in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $validator = Validator::make($data = Input::all(), User::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     try {
         // Create the user
         $user = Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'phone' => $data['phone'], 'activated' => true));
         // Find the group using the group id
         $group = Sentry::findGroupById($data['group']);
         // Assign the group to the user
         $user->addGroup($group);
     } 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.';
     }
     return Redirect::route('users.index');
 }
开发者ID:dynamicsystems,项目名称:TechTracker,代码行数:32,代码来源:UsersController.php

示例6: 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.']);
 }
开发者ID:shampine,项目名称:plumage,代码行数:12,代码来源:ManageController.php

示例7: POST_createUser

 public function POST_createUser()
 {
     try {
         $user = Sentry::createUser(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('full_name'), 'activated' => true));
         $groups = Input::get('groups');
         if (is_array($groups)) {
             foreach ($groups as $key => $group) {
                 $adminGroup = Sentry::findGroupById($group);
                 $user->addGroup($adminGroup);
             }
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $msg = 'Login field is required.';
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $msg = 'Password field is required.';
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         $msg = 'User with this login already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         $msg = 'Group was not found.';
     }
     if (!empty($msg)) {
         return Redirect::to(route('user.list'))->with('STATUS_FAIL', $msg);
     } else {
         return Redirect::to(route('user.list'))->with('STATUS_OK', 'User `' . Input::get('email') . '` successfully created.');
     }
 }
开发者ID:kayrules,项目名称:laravel-starter,代码行数:26,代码来源:UserController.php

示例8: 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()');
     }
 }
开发者ID:ymnl007,项目名称:92five,代码行数:25,代码来源:InstallController.php

示例9: postCreate

 /**
  * Admin.user.create
  */
 public function postCreate()
 {
     // Set permission
     Auth::requirePermissions('admin.user.create');
     try {
         // Find the group using the group id
         $group = \Sentry::findGroupById(\Input::get('group'));
         // Create the user
         $user = \Sentry::createUser(array('email' => strtolower(\Input::get('name')), 'password' => \Input::get('password')));
         // Activate the user
         $user->activated = 1;
         $user->save();
         // Assign the group to the user
         $user->addGroup($group);
     } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) {
         Flash::set('Username is required');
     } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         Flash::set('A password is required');
     } catch (\Cartalyst\Sentry\Users\UserExistsException $e) {
         Flash::set('A user with that username already exists');
     } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         // Illegal group -> ignore
     }
     return \Redirect::to('api/admin/users');
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:28,代码来源:UserController.php

示例10: doRegister

 /**
  * Seed the database with initial value
  *
  * @return void
  */
 public function doRegister()
 {
     try {
         if ($this->_testemail(Input::post('email')) == 0) {
             if (strlen(Input::post('password')) >= 8) {
                 if (Input::post('password') == Input::post('confirm_password')) {
                     $newUser = Sentry::createUser(array('email' => Input::post('email'), 'password' => Input::post('password'), 'first_name' => Input::post('first_name'), 'last_name' => Input::post('last_name'), 'activated' => true));
                     $newUser->save();
                     Response::redirect($this->siteUrl('login'));
                 } else {
                     App::flash('message', 'Les mots de passe ne correspondent pas !');
                     Response::redirect($this->siteUrl('register'));
                 }
             } else {
                 App::flash('message', 'Votre mot de passe est trop court (plus de 8 charactères)');
                 Response::redirect($this->siteUrl('register'));
             }
         } else {
             App::flash('message', 'Votre adresse email n\'est pas valide');
             Response::redirect($this->siteUrl('register'));
         }
     } catch (\Exception $e) {
         Response::redirect($this->siteUrl('register'));
         App::flash('message', $e->getMessage());
     }
 }
开发者ID:vincfleurette,项目名称:weatherapp,代码行数:31,代码来源:HomeController.php

示例11: insert_users

 protected function insert_users()
 {
     for ($i = 0; $i != 20; ++$i) {
         $password = $this->get_random(self::$RANDOM_ALPHA_NUM, 6, 16);
         Sentry::createUser(['password' => $password, 'nickname' => $this->get_random(self::$RANDOM_ALPHA, 4, 12), 'real_name' => $this->get_random(self::$RANDOM_ALPHA, 4, 12), 'phone' => rand(0, count(self::$TELEPHONE_PREFIX)) + $this->get_random(self::$RANDOM_NUM, 8, 8), 'account' => $this->get_random(self::$RANDOM_ALPHA_NUM, 6, 16), 'role' => 1, 'gender' => rand(0, 1), 'activated' => 1]);
     }
 }
开发者ID:Jv-Juven,项目名称:hospital-register-system,代码行数:7,代码来源:InsertTestDataCommand.php

示例12: postAdmin

 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.');
     }
 }
开发者ID:Hounge,项目名称:Android_Push_Server,代码行数:56,代码来源:InstallController.php

示例13: run

 /**
  * 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' => 'admin@admin.com', 'username' => 'admin', 'password' => '123456', 'activated' => true));
     $adminGroup = Sentry::findGroupById(1);
     $user->addGroup($adminGroup);
     Uinfo::create(['uid' => $user->id]);
 }
开发者ID:leebivip,项目名称:laravel_cmp,代码行数:15,代码来源:SentryInitSeeder.php

示例14: run

 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);
 }
开发者ID:ratno,项目名称:Doptor,代码行数:11,代码来源:SentrySeeder.php

示例15: postUlogin

 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);
     }
 }
开发者ID:bitw,项目名称:larulogin,代码行数:54,代码来源:LaruloginController.php


注:本文中的Sentry::createUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。