コード例 #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
ファイル: UsersController.php プロジェクト: eldalo/jarvix
 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);
         }
     }
 }
コード例 #3
0
 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>';
 }
コード例 #4
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;
 }
コード例 #5
0
 /**
  * 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');
 }
コード例 #6
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.']);
 }
コード例 #7
0
 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.');
     }
 }
コード例 #8
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()');
     }
 }
コード例 #9
0
ファイル: UserController.php プロジェクト: jalbertbowden/core
 /**
  * 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');
 }
コード例 #10
0
 /**
  * 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());
     }
 }
コード例 #11
0
 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]);
     }
 }
コード例 #12
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.');
     }
 }
コード例 #13
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]);
 }
コード例 #14
0
ファイル: SentrySeeder.php プロジェクト: ratno/Doptor
 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);
 }
コード例 #15
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);
     }
 }
コード例 #16
0
ファイル: TestCase.php プロジェクト: rafaelvieiras/connect
 /**
  * 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;
 }
コード例 #17
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);
 }
コード例 #18
0
 public function run()
 {
     DB::table('users')->delete();
     Sentry::createUser(array('nickname' => 'hyuyuan', 'password' => '58085088', 'real_name' => '黄裕源', 'phone' => '13580501456', 'account' => 'hyuyuan', 'role' => 7, 'gender' => 1, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'Cobb', 'password' => '123456', 'real_name' => '李四', 'phone' => '13512341234', 'account' => 'Cobb_yuan', 'role' => 3, 'gender' => 1, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'Alies', 'password' => '123123', 'real_name' => '小李子', 'phone' => '18511112222', 'role' => 1, 'gender' => 2, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'adeng', 'password' => '8888888', 'real_name' => '阿登', 'phone' => '18899990000', 'role' => 3, 'gender' => 2, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'hulin', 'password' => 'abcdefg', 'real_name' => '胡琳', 'phone' => '13250502288', 'role' => 2, 'gender' => 1, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'jiali', 'password' => 'bcd123', 'real_name' => '袁嘉丽', 'phone' => '13322225555', 'role' => 1, 'gender' => 2, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'AAA', 'password' => 'AAA', 'real_name' => 'Test', 'phone' => '13022225555', 'account' => '13022225555', 'role' => 2, 'gender' => 2, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'BBB', 'password' => 'BBB', 'real_name' => 'Test', 'phone' => '13122225555', 'account' => '13122225555', 'role' => 2, 'gender' => 2, 'activated' => 1));
     Sentry::createUser(array('nickname' => 'CCC', 'password' => 'CCC', 'real_name' => 'Test', 'phone' => '13222225555', 'account' => '13222225555', 'role' => 2, 'gender' => 2, 'activated' => 1));
 }
コード例 #19
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);
     }
 }
コード例 #20
0
 /**
  * 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'));
 }
コード例 #21
0
 public function create_post()
 {
     $validator = Validator::make(Input::all(), User::get_rules());
     if ($validator->fails()) {
         return Redirect::to('admin/clients/create')->withErrors($validator)->withInput();
     } else {
         $user = Sentry::createUser(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'tin_number' => Input::get('tin_number'), 'landline' => Input::get('landline'), 'mobile' => Input::get('mobile'), 'work_address' => json_endcode(explode(",", Input::get('work_address'))), 'home_address' => json_endcode(explode(",", Input::get('home_address'))), 'company' => Input::get('company'), 'occupation' => Input::get('occupation'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => true));
         // Find the group using the group id
         $group = Sentry::findGroupById(1);
         // Assign the group to the user
         $user->addGroup($group);
         return Redirect::to('admin/clients')->with('success', 'Client account has been successfully created.');
     }
 }
コード例 #22
0
 public function accessToken()
 {
     if (Sentry::check()) {
         return Redirect::to('/pc_home')->with(array('user' => Sentry::getUser()));
     }
     // Session::put('code', Input::get('code'));
     $code = Input::get('code');
     $weixin_data = $this->getAccessTokenByCode($code);
     // var_dump($weixin_data);
     $access_token = $weixin_data['access_token'];
     $refresh_token = $weixin_data['refresh_token'];
     $open_id = $weixin_data['openid'];
     $unionid = $weixin_data['unionid'];
     $user = $this->getUserInfoByAuth($access_token, $open_id);
     $unionid_user = User::where('unionid', '=', $unionid)->first();
     if (!isset($unionid_user)) {
         // try{
         $client_user = Sentry::createUser(array('username' => $user['nickname'], 'avatar' => $user['headimgurl'], 'gender' => $user['sex'], 'email' => $user['unionid'], 'password' => $user['unionid'], 'openid' => $user['openid'], 'unionid' => $user['unionid'], 'activated' => '1'));
         // }
         // catch(Cartalyst\Sentry\Users\PasswordRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserExistsException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // try{
         $user = Sentry::findUserById($client_user->id);
         Sentry::login($user, false);
         // }
         // catch(Cartalyst\Sentry\Users\LoginRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotFoundException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotActivatedException $e)
         // {
         //     return View::make('errors.missing')
         // }
         return Redirect::to('/pc_home')->with(array('user' => $user));
     }
     $user = Sentry::findUserById($unionid_user->id);
     Sentry::login($user, false);
     return Redirect::to('/pc_home')->with(array('user' => $user));
 }
コード例 #23
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), array('email' => 'max:60|email|unique:users', 'password' => 'required|min:6', 'password_again' => 'required|same:password'));
     if ($validator->fails()) {
         return Redirect::route('teacher-account-create')->withErrors($validator)->withInput();
     } else {
         try {
             $email = Input::get('email');
             $password = Input::get('password');
             //Pre activate user
             //$user = Sentry::register(array('email' => $email, 'password' => $password), true);
             //$user = Sentry::register(array('email' => $input['email'], 'password' => $input['password']));
             $user = Sentry::createUser(array('email' => $email, 'password' => $password, 'activated' => 0, 'email_updated_at' => date("Y-m-d h:i:s"), 'password_updated_at' => date("Y-m-d h:i:s")));
             //Get the activation code & prep data for email
             $activationCode = $user->GetActivationCode();
             $userId = $user->getId();
             //send email with link to activate.
             /*Mail::send('emails.register_confirm', $data, function($m) use ($data) {
               $m -> to($data['email']) -> subject('Thanks for Registration - Support Team');
               });*/
             //If no groups created then create new groups
             try {
                 $user_group = Sentry::findGroupById(3);
             } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
                 $this->createGroup('administrator');
                 $this->createGroup('students');
                 $this->createGroup('teacher');
                 $user_group = Sentry::findGroupById(3);
             }
             $user->addGroup($user_group);
             $userDetails = new UserDetails();
             $userDetails->user_id = $userId;
             $userDetails->save();
             //send email
             Mail::send('emails.auth.activate.activate-admin', array('link' => URL::route('admin-account-activate', $activationCode), 'activationCode' => $activationCode, 'userId' => $userId, 'email' => $email), function ($message) use($user) {
                 $message->to($user->email)->subject('Activate Your Account');
             });
             //success!
             Session::flash('global', 'Thanks for sign up . Please activate your account by clicking activation link in your email');
             return Redirect::to(route('teacher-account-create'));
         } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
             Session::flash('global', 'Email Required.');
             return Redirect::to(route('teacher-account-create'))->withErrors($validator)->withInput(Input::except(array('password', 'password_again')));
         } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
             Session::flash('global', 'User Already Exist.');
             return Redirect::to(route('teacher-account-create'))->withErrors($validator)->withInput(Input::except(array('password', 'password_again')));
         }
     }
 }
コード例 #24
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), User::$rules);
     if ($validator->passes()) {
         $group = Sentry::findGroupById(Input::get('role'));
         $outlet_id = Input::get('outlet_id') == 'all' || Input::get('outlet_id') == 0 ? 0 : Input::get('outlet_id');
         // Create the user
         $user = Sentry::createUser(array('email' => Input::get('email'), 'password' => Input::get('password'), 'name' => Input::get('name'), 'phone' => Input::get('phone'), 'address' => Input::get('address'), 'outlet_id' => $outlet_id, 'activated' => Input::get('activated'), 'permissions' => []));
         // Assign the group to the user
         $user->addGroup($group);
         return Redirect::route('users.create')->with('success', 'User created successfully');
     } else {
         return Redirect::route('users.create')->withErrors($validator)->withInput(Input::all());
     }
 }
コード例 #25
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);
     }
 }
コード例 #26
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     try {
         $data = array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'activated' => true);
         // Create the user
         if (Sentry::createUser($data)) {
             return Response::json(array('success' => true, 'message' => 'User Baru Berhasil Ditambahkan'));
         }
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Response::json(array('success' => false, 'message' => 'Field Login diperlukan'));
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Response::json(array('success' => false, 'message' => 'Password diperlukan.'));
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         return Response::json(array('success' => false, 'message' => 'Email sudah Terdaftar'));
     }
 }
コード例 #27
0
 public function run()
 {
     DB::table('tbl_syngroup')->delete();
     DB::table('tbl_synorganizations')->delete();
     DB::table('tbl_synuser')->delete();
     $group1 = Sentry::getGroupProvider()->create(array('name' => 'Student', 'permissions' => array('user.create' => 0, 'user.delete' => 0, 'user.view' => 1, 'user.update' => 1)));
     $group2 = Sentry::getGroupProvider()->create(array('name' => 'Instructor', 'permissions' => array('user.create' => 0, 'user.delete' => 1, 'user.view' => 1, 'user.update' => 1)));
     $group3 = Sentry::getGroupProvider()->create(array('name' => 'Administrator', 'permissions' => array('user.create' => 1, 'user.delete' => 1, 'user.view' => 1, 'user.update' => 1)));
     $org1 = Synergixe\App\Models\Organization::create(array('id' => 'ORG272863989303652', 'org_name' => 'InfoStrategy Tech. Inc.', 'activated' => 1, 'access_name' => 'infostrategy', 'reg_number' => 'RC116070', 'office_address' => 'No. 3 Kaltungo Street, Off Egbedi close, Garki II, Abuja, Nigeria.'));
     $org2 = Synergixe\App\Models\Organization::create(array('id' => 'ORG648835349364903', 'org_name' => 'Dexter And Heroes LLP.', 'activated' => 1, 'access_name' => 'dexterandheroes', 'reg_number' => 'RC547891', 'office_address' => 'Plot 234. Off Faskari Street, Legion House, Garki Area 3, Abuja, Nigeria.'));
     $org3 = Synergixe\App\Models\Organization::create(array('id' => 'ORG834562654677312', 'org_name' => 'Ellen Fashion Enterprises.', 'activated' => 1, 'access_name' => 'ellenfashion', 'reg_number' => 'RC093214', 'office_address' => 'Open Avenue, Off Fastover street, Surulere, Lagos'));
     $user1 = Sentry::createUser(array('id' => 'SYN9365939362946123', 'organization_id' => 'ORG272863989303652', 'password' => 'iknowu101', 'email' => '*****@*****.**', 'first_name' => 'Parry', 'last_name' => 'Stinger', 'sex' => 'male', 'pic_url' => '/assets/thumbs/23zm374ei2528.png', 'mobile_phone' => '08073273629', 'last_login' => '0000-00-00 00:00:00', 'permissions' => array('user.view' => 1)));
     $user2 = Sentry::createUser(array('id' => 'SYN7634290187268208', 'organization_id' => 'ORG648835349364903', 'password' => '232_skeet', 'email' => '*****@*****.**', 'first_name' => 'Omoike', 'last_name' => 'Bobmanuel', 'sex' => 'male', 'pic_url' => '/assets/thumbs/14gxh365e32vx36.png', 'mobile_phone' => '09034625436', 'last_login' => '0000-00-00 00:00:00', 'permissions' => array('user.view' => -1)));
     $user3 = Sentry::createUser(array('id' => 'SYN0632118325708775', 'organization_id' => 'ORG834562654677312', 'password' => 'people4me', 'email' => '*****@*****.**', 'first_name' => 'Tessy', 'last_name' => 'Adazi', 'sex' => 'female', 'pic_url' => '/assets/thumbs/08hejsy283hdf23.png', 'mobile_phone' => '07123268775', 'last_login' => '0000-00-00 00:00:00', 'permissions' => array('superuser' => 1)));
     $user1->addGroup($group1);
     $user2->addGroup($group2);
     $user3->addGroup($group3);
 }
コード例 #28
0
 /**
  * Store a newly registered member
  *
  * @return response
  **/
 public function postRegister()
 {
     $validator = Validator::make(Input::all(), array('first_name' => 'required|min:2', 'last_name' => 'required|min:2', 'membership_no' => 'required', 'email' => 'required|email|max:50|unique:users', 'password' => 'required|min:6', 'confirm_password' => 'required|same:password'));
     if ($validator->fails()) {
         return Redirect::route('account-register')->withErrors($validator)->withInput();
     } else {
         try {
             $user = Sentry::createUser(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'membership_no' => Input::get('membership_no'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => true));
             if ($user) {
                 $userGroup = Sentry::findGroupById(2);
                 $user->addGroup($userGroup);
                 return Redirect::route('home')->with('global', 'A new ' . $userGroup->name . ' has been created!');
             }
         } catch (\Exception $e) {
             return Redirect('account-register')->with('error', $e->getMessage());
         }
     }
 }
コード例 #29
0
 public function storeUserData()
 {
     if (Sentry::check()) {
         return Response::json(array('errCode' => 0, 'message' => '已登录', 'user' => Sentry::getUser()));
     }
     //		Log::info(Input::get('data'));
     $data = json_decode(Input::get('data'));
     //	return Input::get('data');
     $user = User::where('unionid', '=', $data->unionid)->first();
     if (!isset($user)) {
         // try{
         $client_user = Sentry::createUser(array('username' => $data->nickname, 'avatar' => $data->headimgurl, 'gender' => $data->sex, 'email' => $data->unionid, 'password' => $data->unionid, 'openid' => $data->openid, 'unionid' => $data->unionid, 'activated' => '1'));
         // }
         // catch(Cartalyst\Sentry\Users\PasswordRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserExistsException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // try{
         $user = Sentry::findUserById($client_user->id);
         Sentry::login($user, false);
         // }
         // catch(Cartalyst\Sentry\Users\LoginRequiredException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotFoundException $e)
         // {
         //     return View::make('errors.missing');
         // }
         // catch(Cartalyst\Sentry\Users\UserNotActivatedException $e)
         // {
         //     return View::make('errors.missing')
         // }
         return Response::json(array('errCode' => 0, 'message' => '返回参数', 'user' => $user));
     }
     $user = Sentry::findUserById($user->id);
     Sentry::login($user, false);
     return Response::json(array('errCode' => 0, 'message' => '返回参数', 'user' => $user));
 }
コード例 #30
0
ファイル: UserController.php プロジェクト: dbirchak/ping
 public function loginGithub()
 {
     $code = Input::get('code');
     $email = Input::get('email');
     $github = OAuth::consumer('GitHub');
     if (!empty($email)) {
         $user = User::where('email', '=', $email)->first();
         if (isset($user)) {
             Session::flash('warning', trans('user.register.social.already-exists'));
             return Redirect::route('user.register');
         }
         $user = Sentry::createUser(array('email' => $email, 'password' => md5(time() . uniqid()), 'activated' => true));
         UserGitHub::create(array('user_id' => $user->id, 'access_token' => Input::get('access_token'), 'refresh_token' => !empty(Input::get('refresh_token')) ? Input::get('refresh_token') : null, 'end_of_life' => !empty(Input::get('end_of_life')) ? Input::get('end_of_life') : null));
         $user = Sentry::findUserByLogin($user->email);
         Sentry::login($user, false);
         Session::flash('success', trans('user.register.social.success'));
         return Redirect::route('home');
     } elseif (empty($code)) {
         $url = $github->getAuthorizationUri(array('state' => md5(time() . uniqid()), 'redirect_uri' => URL::route('user.login.github')));
         return Response::make()->header('Location', (string) $url);
     } else {
         $token = $github->requestAccessToken($code);
         $emails = json_decode($github->request('/user/emails'), true);
         if (!is_array($emails) || count($emails) === 0) {
             Session::flash('error', trans('user.register.social.no-emails'));
             return Redirect::route('user.register');
         }
         if (count($emails) <= 1) {
             $user = User::where('email', '=', $emails[0])->first();
             if (isset($user)) {
                 Session::flash('warning', trans('user.register.social.already-exists'));
                 return Redirect::route('user.register');
             }
             $user = Sentry::createUser(array('email' => $emails[0], 'password' => md5(time() . uniqid()), 'activated' => true));
             UserGitHub::create(array('user_id' => $user->id, 'access_token' => $token->getAccessToken(), 'refresh_token' => !empty($token->getRefreshToken()) ? $token->getRefreshToken() : null, 'end_of_life' => !empty($token->getEndOfLife()) ? $token->getEndOfLife() : null));
             Sentry::login($user, false);
             Session::flash('success', trans('user.register.social.success'));
             return Redirect::route('home');
         }
         return View::make('user.social', array('emails' => $emails, 'token' => $token));
     }
 }