/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => '12345678', 'first_name' => 'Administrador', 'last_name' => 'Kentron', 'activated' => 1]); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => '12345678', 'first_name' => 'Invitado', 'last_name' => 'Kentron', 'activated' => 1]); $this->command->info('Users seeded!'); }
public function run() { DB::table('users')->delete(); DB::table('groups')->delete(); DB::table('users_groups')->delete(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'admin', 'last_name' => 'admin', 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Super Admin', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Office Admin', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Project Manager', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Team Leader', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Developer', 'permissions' => array('admin' => 1))); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'Ashok', 'last_name' => 'Adhikari', 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "santosh", 'first_name' => 'Santosh', 'last_name' => 'Dhungana', 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "dinesh", 'first_name' => 'Dinesh', 'last_name' => 'Sharma', 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "asheem", 'first_name' => 'Asheem', 'last_name' => 'Manandhar', 'activated' => 1)); // Assign user permissions $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Super Admin'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Office Admin'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Project Manager'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Team Leader'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Developer'); $adminUser->addGroup($adminGroup); }
/** * Execute the console command. * * @return void */ public function fire() { try { $email = $this->argument('email'); $pass = $this->argument('password'); $username = $this->argument('username'); $groupName = $this->argument('group'); $validator = new UserValidator(array('email' => $email, 'pass' => $pass, 'username' => $username), 'create'); if (!$validator->passes()) { foreach ($validator->getErrors() as $key => $messages) { $this->info(ucfirst($key) . ' :'); foreach ($messages as $message) { $this->error($message); } } } else { // Create the user $user = \Sentry::getUserProvider()->create(array('email' => $email, 'password' => $pass, 'username' => $username)); $activationCode = $user->getActivationCode(); $user->attemptActivation($activationCode); if ($groupName !== NULL) { $group = \Sentry::getGroupProvider()->findByName($groupName); $user->addGroup($group); } $this->info('User created with success'); } } catch (\Cartalyst\Sentry\Users\UserExistsException $e) { $this->error('User already exists !'); } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) { $this->error('Group ' . $groupName . ' does not exists !'); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->truncate(); $userUser1 = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userUser2 = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userUser3 = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userUser4 = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userUser5 = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $clinic1User = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $clinic2User = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $doctor1User = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $doctor2User = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $doctor3User = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userGroup = Sentry::getGroupProvider()->findByName('Patients'); $doctorsyGroup = Sentry::getGroupProvider()->findByName('Doctors'); $clinicGroup = Sentry::getGroupProvider()->findByName('Clinics'); $adminGroup = Sentry::getGroupProvider()->findByName('Admins'); // Assign the groups to the users $userUser1->addGroup($userGroup); $userUser2->addGroup($userGroup); $userUser3->addGroup($userGroup); $userUser4->addGroup($userGroup); $userUser5->addGroup($userGroup); $clinic1User->addGroup($clinicGroup); $clinic2User->addGroup($clinicGroup); $doctor1User->addGroup($doctorsyGroup); $doctor2User->addGroup($doctorsyGroup); $doctor3User->addGroup($doctorsyGroup); $adminUser->addGroup($adminGroup); }
public function login() { try { $user = Sentry::getUserProvider()->findByLogin(Input::json('email')); $throttle = Sentry::getThrottleProvider()->findByUserId($user->id); $throttle->setSuspensionTime(10); $throttle->setAttemptLimit(3); $throttle->check(); $credentials = ['email' => Input::json('email'), 'password' => Input::json('password')]; $user = Sentry::authenticate($credentials, false); } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) { return Response::json(array('flash' => 'Invalid username or password'), 500); } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { return Response::json(array('flash' => 'Login field is required'), 500); } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { return Response::json(array('flash' => 'Password field is required'), 500); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { return Response::json(array('flash' => 'Invalid username or password'), 500); } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { return Response::json(array('flash' => 'This account is inactive'), 500); } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) { $time = $throttle->getSuspensionTime(); return Response::json(array('flash' => 'This account is suspended for ' . $time . ' minutes'), 500); } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) { return Response::json(array('flash' => 'This account has been banned'), 500); } $user_details = User::join('users_groups', 'users.id', '=', 'users_groups.user_id')->join('groups', 'users_groups.group_id', '=', 'groups.id')->where('users.id', '=', $user->id)->select('users.id', 'users.email', 'users.first_name', 'users.last_name', 'groups.name as role', 'users.activated_at', 'users.last_login', 'users.created_at', 'users.updated_at')->get(); return Response::json($user_details[0], 200); }
/** * Sends Forgot Password Email * @param string * @return bool */ public static function sendForgotPasswordEmail($email) { try { // Find the user using the user email address $user = Sentry::getUserProvider()->findByLogin($email); // Get the password reset code $resetCode = $user->getResetPasswordCode(); //send this code to your user via email. $name = $user->first_name . ' ' . $user->last_name; $link = (string) url() . '/auth/recoverpassword?password_reset_token=' . $resetCode . '&email=' . $email; $data = array('name' => $name, 'link' => $link); Mail::queue('emails.auth.forgotpassword', $data, function ($message) use($user) { $message->to($user->email)->subject('Forgot Password Assistance'); }); return true; } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { return Redirect::to('login')->with('message', 'error104'); } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) { return Redirect::to('login')->with('message', 'error103'); } catch (Cartalyst\Sentry\Users\UserSuspendedException $e) { return Redirect::to('login')->with('message', 'error105'); } catch (Cartalyst\Sentry\Users\UserBannedException $e) { return Redirect::to('login')->with('message', 'error102'); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123456', 'prenume' => 'UserFirstName', 'nume' => 'UserLastName', 'id_organizatie' => 1, 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123456', 'prenume' => 'AdminFirstName', 'nume' => 'AdminLastName', 'id_organizatie' => 1, 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => 'admin', 'password' => '123', 'prenume' => 'AdminFirstName', 'nume' => 'AdminLastName', 'id_organizatie' => 1, 'activated' => 1)); }
public function postAddnewUser() { try { $Users = Sentry::getUserProvider()->create(array('email' => Input::get('email'), 'password' => Input::get('password'), 'activated' => 1, 'staff' => 1)); $staff_id = $Users->id; } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { return Redirect::to('dashboard/agencies/view/addnewuser')->with('errors', 'email field is required'); } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { return Redirect::to('dashboard/agencies/view/addnewuser')->with('errors', 'Password field is required'); } catch (Cartalyst\Sentry\Users\UserExistsException $e) { return Redirect::to('dashboard/agencies/view/addnewuser')->withInput()->with('errors', 'User with this login already exists'); } $URL = 'Email:' . ' ' . Input::get('email') . '<br/><br/>' . 'Password:'******' ' . Input::get('password') . '<br/><br/>' . 'Link:' . ' ' . 'http://' . $_SERVER['HTTP_HOST']; $this->sendTo(Input::get('email'), array('activationCode' => $URL)); $fields = array('email' => Input::get('email'), 'password' => Input::get('password'), 'name' => Input::get('name'), 'phone' => Input::get('phone'), 'cell' => Input::get('cell'), 'fax' => Input::get('fax'), 'address' => Input::get('address'), 'zip' => Input::get('zip'), 'country' => Input::get('country'), 'listing_quota' => Input::get('listing_quota'), 'hot_quota' => Input::get('hot_quota')); $rules = array('email' => 'required', 'password' => 'required|min:6', 'name' => 'required', 'cell' => 'required', 'address' => 'required', 'country' => 'required', 'zip' => 'required', 'fax' => 'required', 'listing_quota' => 'required', 'hot_quota' => 'required'); $v = Validator::make($fields, $rules); if ($v->fails()) { return Redirect::to('addnewuser')->with('errors', $v); } $agency_id = Input::get('agency_name'); $ownerids = AgentUser::where('id', '=', $agency_id)->get(); foreach ($ownerids as $ownerid) { $owner_id = $ownerid->agent_id; } DB::table('Agencystaff')->insertGetId(array('agency_id' => Input::get('agency_name'), 'staff_id' => $staff_id, 'owner_id' => $owner_id, 'email' => Input::get('email'), 'name' => Input::get('name'), 'phone' => Input::get('phone'), 'cell' => Input::get('cell'), 'fax' => Input::get('fax'), 'address' => Input::get('address'), 'zip' => Input::get('zip'), 'country' => Input::get('country'), 'listing_quota' => Input::get('listing_quota'), 'hot_quota' => Input::get('hot_quota'))); DB::table('registration')->insertGetId(array('user_id' => $staff_id, 'name' => Input::get('name'), 'phone' => Input::get('phone'), 'cell' => Input::get('cell'), 'fax' => Input::get('fax'), 'address' => Input::get('address'), 'zip' => Input::get('zip'), 'country' => Input::get('country'), 'photo' => $this->ImageCrop('photo', 'photos', '200', '200', ''))); $proimg = Input::file('photo'); return Redirect::to('dashboard/agencies')->with('success', 'successfully Added'); }
public function admin_post() { $rules = array('email' => 'required|email'); if (Input::has('password')) { $rules['password'] = '******'; } $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('settings')->withErrors($validator)->withInput(); } else { try { // Find the user using the user id $user = Sentry::getUserProvider()->findById($this->data['admin']->id); // Update the user details $user->email = Input::get('email'); $user->first_name = Input::get('password'); // Update the user if ($user->save()) { return Redirect::to('settings')->with('success', 'User information was updated.'); } else { return Redirect::to('settings')->with('error', 'User information was not updated.'); } } catch (Cartalyst\Sentry\Users\UserExistsException $e) { return Redirect::to('settings')->with('error', 'User with this login already exists.'); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { return Redirect::to('settings')->with('error', 'User was not found.'); } } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => 'sentryuser', 'first_name' => 'UserFirstName', 'last_name' => 'UserLastName', 'activated' => 1]); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => 'sentryadmin', 'first_name' => 'AdminFirstName', 'last_name' => 'AdminLastName', 'activated' => 1]); $this->command->info('Users seeded!'); }
public function run() { DB::table('users_groups')->delete(); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Admin'); // Assign the groups to the users $adminUser->addGroup($adminGroup); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('tutorials')->delete(); Eloquent::unguard(); try { // Create the group $group = Sentry::getGroupProvider()->create(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 { // Create the group $group = Sentry::getGroupProvider()->create(array('name' => 'teachers', 'permissions' => array('create_tutorial' => 1, 'update_tutorial' => 1, 'create_exam' => 1, 'update_exam' => 1, 'see_results' => 1, 'see_result' => 1))); } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) { echo 'Name field is required'; } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) { echo 'Group already exists'; } try { // Create the group $group = Sentry::getGroupProvider()->create(array('name' => 'students', 'permissions' => array('see_tutorial' => 1, 'do_exam' => 1, 'see_result' => 1))); } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) { echo 'Name field is required'; } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) { echo 'Group already exists'; } try { // Create the user $user = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => 'user123456', 'activated' => '1', 'first_name' => 'John', 'last_name' => 'Doe', 'permissions' => array('user.create' => 1, 'user.delete' => 1, 'user.view' => 1, 'user.update' => 1))); // Find the group using the group id $adminGroup = Sentry::getGroupProvider()->findById(1); // Assign the group to the user $user->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.'; } $admin = Sentry::getGroupProvider()->findByName('admin'); $tea = Sentry::getGroupProvider()->findByName('teachers'); $stu = Sentry::getGroupProvider()->findByName('students'); $user = Sentry::getUserProvider()->findById(1); $user->addGroup($admin); $user->addGroup($tea); $user->addGroup($stu); unset($admin); unset($user); $this->call('TeacherTableSeeder'); $this->call('StudentTableSeeder'); $this->call('SubjectTableSeeder'); }
public function run() { Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123456', 'first_name' => 'Admin', 'last_name' => 'Romy Rafael', 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => array('admin' => 1, 'users' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Users', 'permissions' => array('admin' => 0, 'users' => 1))); // Assign user permissions $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Admin'); $adminUser->addGroup($adminGroup); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->delete(); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userGroup = Sentry::getGroupProvider()->findByName('Users'); $adminGroup = Sentry::getGroupProvider()->findByName('Admins'); // Assign the groups to the users $adminUser->addGroup($userGroup); $adminUser->addGroup($adminGroup); }
public function run() { DB::table('users_groups')->delete(); $user = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $admin = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $usersGroup = Sentry::getGroupProvider()->findByName('Users'); $adminsGroup = Sentry::getGroupProvider()->findByName('Admins'); $user->addGroup($usersGroup); $admin->addGroup($adminsGroup); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->delete(); $adminUser = Sentry::getUserProvider()->findByLogin(''); //initial user email, same as EntryUserSeeder $adminGroup = Sentry::getGroupProvider()->findByName('Admins'); $modGroup = Sentry::getGroupProvider()->findByName('Mods'); // Assign the groups to the users $adminUser->addGroup($modGroup); $adminUser->addGroup($adminGroup); }
/** * Run the database seeds. * * @return void */ public function run() { $this->command->info('Seeding: CustomSentryUserGroupSeeder Class...'); DB::table('users_groups')->delete(); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userGroup = Sentry::getGroupProvider()->findByName('Users'); $adminGroup = Sentry::getGroupProvider()->findByName('Admins'); // Assign the groups to the users $adminUser->addGroup($userGroup); $adminUser->addGroup($adminGroup); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->delete(); $userUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userGroup = Sentry::getGroupProvider()->findByName('Pengguna'); $adminGroup = Sentry::getGroupProvider()->findByName('Pentadbir'); // Assign the groups to the users $userUser->addGroup($userGroup); $adminUser->addGroup($userGroup); $adminUser->addGroup($adminGroup); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->delete(); $userUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userGroup = Sentry::getGroupProvider()->findByName('Users'); $adminGroup = Sentry::getGroupProvider()->findByName('Admins'); // Assign the groups to the users $userUser->addGroup($userGroup); $adminUser->addGroup($adminGroup); $this->command->info('Users assigned to groups seeded!'); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users_groups')->delete(); $userUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $userGroup = Sentry::getGroupProvider()->findByName('Users'); $adminGroup = Sentry::getGroupProvider()->findByName('Admins'); // Assign the groups to the users $userUser->addGroup($userGroup); $adminUser->addGroup($userGroup); $adminUser->addGroup($adminGroup); }
public function run() { DB::table('users')->delete(); DB::table('groups')->delete(); DB::table('users_groups')->delete(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'John', 'last_name' => 'Doe', 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => array('admin' => 1))); // Assign user permissions $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Admin'); $adminUser->addGroup($adminGroup); }
public function run() { DB::table('users')->delete(); DB::table('groups')->delete(); DB::table('users_groups')->delete(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "ooxx", 'first_name' => 'OO', 'last_name' => 'XX', 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => ['admin' => 1])); // 将用户加入用户组 $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Admin'); $adminUser->addGroup($adminGroup); }
public function run() { DB::table('users')->truncate(); // Using truncate function so all info will be cleared when re-seeding. DB::table('groups')->truncate(); DB::table('users_groups')->truncate(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'John', 'last_name' => 'McClane', 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => array('admin' => 1))); // Assign user permissions $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Admin'); $adminUser->addGroup($adminGroup); }
/** * Execute the console command. * * @return mixed */ public function fire() { $create = $this->option('create'); $delete = $this->option('delete'); if (!empty($create)) { $name = $this->ask('Enter the name of the user:'******'Enter the name of the user:'******'Enter the password for the user:'******'Make sure the password is longer than 5 characters'); $password = $this->secret('Enter the password for the user:'******'Re-enter the password to confirm:'); while ($pwConfirm != $password) { $pwConfirm = $this->secret('The passwords did not match, re-enter the password to confirm:'); } // Create 'everyone' user and group Sentry::getUserProvider()->create(array('email' => $name, 'password' => $pwConfirm, 'first_name' => $name, 'last_name' => '', 'activated' => 1)); $newUser = Sentry::getUserProvider()->findByLogin($name); $adminGroup = Sentry::getGroupProvider()->findByName('superadmin'); $newUser->addGroup($adminGroup); $this->info('The user ' . $name . ' has been created and activated.'); } else { if (!empty($delete)) { $name = $this->ask('Enter the name of the user you want to delete.'); while (empty($name)) { $name = $this->ask('Enter the name of the user you want to delete.'); } $user = User::where(['email' => $name])->first(); if (empty($user)) { $this->error('No user with the name ' . $name . ' has been found.'); } else { if ($this->confirm('The user ' . $name . ' has been found, are you sure you want do delete? [yes|no]')) { $user->delete(); } else { $this->info('The user ' . $name . ' has not been removed.'); } } } else { // Get all of the users $users = User::all(['email'])->toArray(); foreach ($users as $user) { if ($user['email'] != 'everyone') { $this->info($user['email']); } } } } }
public function store() { $data = array("first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email"), "username" => Input::get("username"), "phone" => Input::get("phone"), "picture" => Input::file("picture"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation")); $rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|email|unique:users', "username" => 'required|min:5|unique:users', "phone" => 'required|min:1|max:100', "picture" => 'mimes:jpeg,gif,png', 'password' => 'confirmed|min:6'); $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png', 'unique' => 'El :attribute ingresado ya esta siendo usaddo por otro usuario.', 'confirmed' => 'La confirmación del :attribute no coincide'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores //y con los campos que nos habia llenado el usuario if ($validation->fails()) { return Redirect::to('/clinic/users/create')->withErrors($validation)->withInput(); } else { $user = new User(); $user->first_name = Input::get("first_name"); $user->last_name = Input::get("last_name"); $user->email = Input::get("email"); $user->username = Input::get("username"); $user->password = Input::get("password"); $user->activated = 1; $user->save(); $doctorUser = Sentry::getUserProvider()->findByLogin($user->email); $doctorsyGroup = Sentry::getGroupProvider()->findByName('Receptionist'); $doctorUser->addGroup($doctorsyGroup); $Receptionist = new UserReceptionist(); $Receptionist->user_id = $user->id; $Receptionist->clinic_id = Clinic::getClinicId(); if (Input::file('picture') != NULL) { //agrega imagen de logo $file_logo = Input::file('picture'); $ext = Input::file('picture')->getClientOriginalExtension(); $nameIMG = date('YmdHis'); $logo = $nameIMG . '.' . $ext; $logo = 'assets/doctor/images/profile_pic/profile_' . $logo; $file_logo->move("assets/doctor/images/profile_pic/", $logo); } $Receptionist->save(); if (!$logo) { $logo = ""; } $profile = new Profile(); $profile->user_id = $user->id; $profile->lang = Input::get("lang"); $profile->phone = Input::get("phone"); $profile->picture = $logo; $profile->save(); if ($profile) { return Redirect::to('/clinic/users/')->withFlash_message("Guardado Exitosamente"); } else { return Redirect::to('/clinic/users/create')->withErrors("Error")->withInput(); } } }
public function run() { DB::table('users')->truncate(); DB::table('groups')->truncate(); DB::table('users_groups')->truncate(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => 'admin', 'first_name' => 'Demo', 'last_name' => 'User', 'permissions' => (array) json_decode('{"superuser":1}'), 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Admin', 'permissions' => (array) json_decode('{"dashboard":1,"admin.settings.index":1,"admin.pages.index":1,"admin.pages.view":1,"admin.pages.create":1,"admin.pages.store":1,"admin.pages.edit":1,"admin.pages.sort":1,"admin.pages.destroy":1,"admin.files.index":1,"admin.files.view":1,"admin.files.create":1,"admin.files.store":1,"admin.files.edit":1,"admin.files.sort":1,"admin.files.destroy":1,"admin.news.index":1,"admin.news.view":1,"admin.news.create":1,"admin.news.store":1,"admin.news.edit":1,"admin.news.sort":1,"admin.news.destroy":1,"admin.events.index":1,"admin.events.view":1,"admin.events.create":1,"admin.events.store":1,"admin.events.edit":1,"admin.events.sort":1,"admin.events.destroy":1,"admin.categories.index":1,"admin.categories.view":1,"admin.categories.create":1,"admin.categories.store":1,"admin.categories.edit":1,"admin.categories.sort":1,"admin.categories.destroy":1,"admin.projects.index":1,"admin.projects.view":1,"admin.projects.create":1,"admin.projects.store":1,"admin.projects.edit":1,"admin.projects.sort":1,"admin.projects.destroy":1,"admin.places.index":1,"admin.places.view":1,"admin.places.create":1,"admin.places.store":1,"admin.places.edit":1,"admin.places.sort":1,"admin.places.destroy":1,"admin.menus.index":1,"admin.menus.view":1,"admin.menus.create":1,"admin.menus.store":1,"admin.menus.edit":1,"admin.menus.sort":1,"admin.menus.destroy":1,"admin.menulinks.index":1,"admin.menulinks.view":1,"admin.menulinks.create":1,"admin.menulinks.store":1,"admin.menulinks.edit":1,"admin.menulinks.sort":1,"admin.menulinks.destroy":1,"admin.users.index":1,"admin.users.view":1,"admin.users.create":1,"admin.users.store":1,"admin.users.edit":1,"admin.users.sort":1,"admin.users.destroy":1,"admin.groups.index":1,"admin.groups.view":1,"admin.groups.create":1,"admin.groups.store":1,"admin.groups.edit":1,"admin.groups.sort":1,"admin.groups.destroy":1}'))); Sentry::getGroupProvider()->create(array('name' => 'Public', 'permissions' => array())); Sentry::getGroupProvider()->create(array('name' => 'News', 'permissions' => (array) json_decode('{"dashboard":1,"admin.news.index":1,"admin.news.view":1,"admin.news.create":1,"admin.news.store":1,"admin.news.edit":1,"admin.news.sort":1,"admin.news.destroy":1}'))); // Assign user permissions $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Admin'); $adminUser->addGroup($adminGroup); }
/** * 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, )); */ }
/** * * * @return void */ public function callback() { $config = Config::get('opauth'); $Opauth = new Opauth($config, FALSE); if (!session_id()) { session_start(); } $response = isset($_SESSION['opauth']) ? $_SESSION['opauth'] : array(); $err_msg = null; unset($_SESSION['opauth']); if (array_key_exists('error', $response)) { $err_msg = 'Authentication error:Opauth returns error auth response.'; } else { if (empty($response['auth']) || empty($response['timestamp']) || empty($response['signature']) || empty($response['auth']['provider']) || empty($response['auth']['uid'])) { $err_msg = 'Invalid auth response: Missing key auth response components.'; } elseif (!$Opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason)) { $err_msg = 'Invalid auth response: ' . $reason; } } if ($err_msg) { return Redirect::to('account/login')->with('error', $err_msg); } else { $email = $response['auth']['info']['email']; $authentication = new Authentication(); $authentication->provider = $response['auth']['provider']; $authentication->provider_uid = $response['auth']['uid']; $authentication_exist = Authentication::where('provider', $authentication->provider)->where('provider_uid', '=', $authentication->provider_uid)->first(); if (!$authentication_exist) { if (Sentry::check()) { $user = Sentry::getUser(); $authentication->user_id = $user->id; } else { try { $user = Sentry::getUserProvider()->findByLogin($email); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { $user = Sentry::register(array('first_name' => $response['auth']['info']['first_name'], 'last_name' => $response['auth']['info']['last_name'], 'email' => $email, 'password' => Str::random(14)), TRUE); } $authentication->user_id = $user->id; } $authentication->save(); } else { $user = Sentry::getUserProvider()->findById($authentication_exist->user_id); Sentry::login($user); Session::put('user_image', $response['auth']['info']['image']); return Redirect::to('/'); } } }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); /** * admin group seed */ try { // Create the group $group = Sentry::getGroupProvider()->create(array('name' => 'Admins', 'permissions' => array('admin' => 1, 'users' => 1))); } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) { echo 'Name field is required'; } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) { echo 'Group already exists'; } /** * user group seed */ try { // Create the group $group = Sentry::getGroupProvider()->create(array('name' => 'Users', 'permissions' => array('admin' => 0, 'users' => 1))); } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) { echo 'Name field is required'; } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) { echo 'Group already exists'; } /** * admin seed */ try { // Create theuser $user = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => 'test', 'permissions' => array('admin' => 1), 'activated' => 1)); // Find the group using the group id $adminGroup = Sentry::getGroupProvider()->findById(1); // Assign the group to the user $user->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 login already exists.'; } /** * table seed */ }
/** * 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); }