public function postUlogin() { $_user = json_decode(file_get_contents('http://ulogin.ru/token.php?token=' . Input::get('token') . '&host=' . $_SERVER['HTTP_HOST']), true); $validate = Validator::make([], []); if (isset($_user['error'])) { return Redirect::to('/#popup=enter'); } if ($check = Ulogin::where('identity', '=', $_user['identity'])->first()) { if ($user = User::where('id', $check->user_id)->first()) { Auth::loginUsingId($user->id, true); return Redirect::to(AuthAccount::getGroupStartUrl()); } else { return Redirect::back(); } } elseif (isset($_user['email']) && User::where('email', $_user['email'])->exists()) { $userID = User::where('email', $_user['email'])->pluck('id'); self::createULogin($userID, $_user); Auth::loginUsingId($userID, TRUE); return Redirect::to(AuthAccount::getGroupStartUrl()); } else { $rules = array('network' => 'required|max:255', 'identity' => 'required|max:255|unique:ulogin', 'email' => 'required|unique:ulogin|unique:users'); $validate = Validator::make($_user, $rules); if ($validate->passes()) { return Redirect::to('/#popup=reg')->with('token', Input::get('token'))->with('email', @$_user['email'])->with('identity', @$_user['identity'])->with('profile', @$_user['profile'])->with('first_name', @$_user['first_name'])->with('last_name', @$_user['last_name'])->with('city', @$_user['city'])->with('uid', @$_user['uid'])->with('photo_big', @$_user['photo_big'])->with('photo', @$_user['photo'])->with('network', @$_user['network'])->with('verified_email', @$_user['verified_email']); } else { return Redirect::to('/#popup=enter'); } } }
public function loginByToken($token) { $user = User::Where('remember_token', $token)->first(); Auth::loginUsingId($user->id, true); $htmltree = MemberAPI::getmemberchilds($user->id); return Redirect::to(Auth::user()->roleString() . '/dashboard')->with('htmltree', $htmltree); }
function testGetInactiveItemsWhenLoggedIn() { \Auth::loginUsingId(1); $post = new TestPost(); $posts = $post->setOrderBy(array('title' => 'asc', 'date' => 'desc'))->first(); $this->assertEquals('new-year-update', $posts->slug); }
public function setUp() { parent::setUp(); $databaseUrl = __DIR__ . '/../tests/studs/testing.sqlite'; $runMigrate = false; $fileSystem = new \Illuminate\Filesystem\Filesystem(); if (!$this->inMemoryDb && !$fileSystem->exists($databaseUrl)) { $fileSystem->put($databaseUrl, ''); $runMigrate = true; fwrite(STDOUT, "\r\n- Migrate \r\n"); } $this->app['config']->set('app.key', 'SomeRandomStringWith32Characters'); $this->app['config']->set('app.debug', true); $this->app['config']->set('database.default', 'sqlite'); $this->app['config']->set('database.connections.sqlite.database', $this->inMemoryDb ? ':memory:' : $databaseUrl); if ($runMigrate || $this->inMemoryDb) { $this->migrate(); $this->createSiteAndAdminUser(); } // generally it is not run during console calls, but it is ok for testing, because // system knows that site's url is localhost app('veer')->run(); $admin = \Veer\Models\UserAdmin::where('banned', 0)->first(); \Auth::loginUsingId($admin->users_id); }
/** * Stage Three - After Duo Auth Form * @return Redirect to home */ public function postDuologin() { /** * Sent back from Duo */ $response = $_POST['sig_response']; $U = $this->_laravelDuo->verifyResponse($this->_laravelDuo->get_ikey(), $this->_laravelDuo->get_skey(), $this->_laravelDuo->get_akey(), $response); /** * Duo response returns USER field from Stage Two */ if ($U) { /** * Get the id of the authenticated user from their email address */ $id = User::getIdFromUsername($U); /** * Log the user in by their ID */ Auth::loginUsingId($id); /** * Check Auth worked, redirect to homepage if so */ if (Auth::check()) { return Redirect::to('/'); } } /** * Otherwise, Auth failed, redirect to homepage with message */ return Redirect::to('/')->with('message', 'Unable to authenticate you.'); }
/** * Store a newly created User in storage. * POST /users * * @return Response */ public function signUp() { $manager = new RegisterUserManager(new User(), Input::instance()); $manager->save(); Auth::loginUsingId($manager->getModel()->id); return Redirect::route('users.show', [$manager->getModel()->slug]); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); // Delete any images that were previously uploaded $this->rrmdir(storage_path('edited_images')); $this->rrmdir(storage_path('original_images')); $this->rrmdir(public_path('images')); // Clear form uploads $this->rrmdir(storage_path('buildingQuote')); $this->rrmdir(storage_path('employmentApp')); $this->rrmdir(storage_path('contactForm')); $this->rrmdir(storage_path('creditApp')); $this->call('RoleTableSeeder'); $this->call('PermissionTableSeeder'); $this->call('UserTableSeeder'); Auth::loginUsingId(1); $this->call('LocationTableSeeder'); $this->call('AddLocationsToUsers'); $this->call('EmployeeTableSeeder'); $this->call('ImageProfileTableSeeder'); $this->call('TestimonialsTableSeeder'); $this->call('FormSettingsTableSeeder'); $this->call('NewsArticleTableSeeder'); $this->call('SpecialsTableSeeder'); $this->call('GaugeTableSeeder'); $this->call('ColorTableSeeder'); $this->call('ProfileTableSeeder'); $this->call('PageTableSeeder'); $this->call('GalleryTablesSeeder'); $this->call('FormRotationsTableSeeder'); $this->call('ZipCodeTableSeeder'); }
/** * Display a listing of the resource. * * @param Request $request * @return Response */ public function index(Request $request) { \Auth::loginUsingId(1); if ($request->ajax()) { return Auth::user()->daycare->children()->with('room')->orderBy('last_name', 'ASC')->orderBy('first_name', 'ASC')->get(); } return view('saferoll.children.index'); }
public function testBackendAdmin() { $routes = ['admin/user/create', 'admin/user/update', 'admin/user/review', 'admin/user/register', 'admin/user/registersuccess']; Route::enableFilters(); Auth::loginUsingId(5); foreach ($routes as $route) { $this->check('GET', $route); } }
public function setUp() { parent::setUp(); Auth::loginUsingId(1); $this->test_dummy = factory($this->model_class)->make(); $this->test_dummy_attributes = $this->test_dummy->toArray(); unset($this->test_dummy_attributes['updated_at_for_humans']); unset($this->test_dummy_attributes['identifiable_name']); }
public function activateAccount($token) { $user = User::whereActivateToken($token)->firstOrFail(); $user->is_active = (int) true; $user->activate_token = null; $user->save(); Auth::loginUsingId($user->id); return Alert::flash(Lang::get('auth.activated'), 'success'); }
/** * Invite emails * **/ public function inviteEmail($token) { $message = $this->user->verifyEmail($token); //now login and direct to password reset form $email = \DB::table('user_tokens')->where('token', $token)->pluck('email'); $user = \User::where('email', $email)->first(); Auth::loginUsingId($user->_id); return Redirect::to('/users/' . $user->_id . '/add/password'); }
/** * Método estático. Lo uso para que me devuelva el id del usuario que está ingresando **/ static function getIdByName($name) { $user = User::where('email', '=', $name)->get(); if (isset($user[0])) { $id = $user[0]->id; Auth::loginUsingId($id); return true; } return Redirect::to('login_get'); }
public function postLaravelLogin() { $post = json_decode(file_get_contents("php://input")); if (User::checkFBUser($post->fb_id) && !Auth::check()) { Auth::loginUsingId(User::getUserIdByFbId($post->fb_id)); $success = 1; } else { $success = 0; } return json_encode(array('success' => $success)); }
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); } }
public function run() { // Get the categories subtree of the first root category $categories = Category::roots()->first()->getDescendantsAndSelf(); // Pretend first ser has logged in Auth::loginUsingId($i = 1); // Add a page for each category of the subtree foreach ($categories as $category) { Page::create(['name' => "Page {$i}", 'source' => "Content of page {$i}", 'category_id' => $category->id]); $i++; } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $data = $this->request->all(); $rules = array('email' => 'required|min:4|max:254|email', 'password' => 'required|min:6|confirmed', 'username' => 'required'); $validation = $this->validator->validate($data, $rules); if ($validation === true) { $user = $this->user->create(array('email' => $data['email'], 'password' => Hash::make($data['password']), 'username' => $data['username'])); Auth::loginUsingId($user->id); return Redirect::route('dashboard')->withSuccess("Welcome {$user->username} to Event Manager!!"); } return Redirect::route('register')->withInput()->withErrors($validation); }
public function login() { $username = Input::get('username'); $password = Input::get('password'); $is_json = Input::get('method') == 'json'; $user = User::where('username', '=', $username)->where('password', '=', $password)->first(); if ($user != null) { Auth::loginUsingId($user->id); return Response::json(['success' => true]); } return Response::json(['success' => false, 'messages' => 'Username and password dismatch.']); }
/** * Handle a registration request for the application. * * @param CreateUserRequest|\Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postRegister(CreateUserRequest $request) { $username = $request->username; $mail = $request->mail; $pass = Hash::make($request->pass); //Create user without profile image, can be added in later under settings storeUser(new User(['username' => $username, 'mail' => $mail, 'pass' => $pass, 'score' => 0])); flash()->success("Welcome, tell us something about yourself or edit your account in the 'Users' section."); $user = loadUser($username); \Auth::loginUsingId($user[0]->id); return redirect("/"); }
/** * Invite emails * **/ public function inviteEmail($token) { $message = $this->user->verifyEmail($token); //now login and direct to password reset form $email = \DB::table('user_tokens')->where('token', $token)->pluck('email'); $user = \User::where('email', $email)->first(); if (!isset($user->_id)) { \App::abort(404, 'This token cannot be found or has expired.'); } Auth::loginUsingId($user->_id); \DB::table('user_tokens')->where('token', $token)->delete(); return Redirect::to('/users/' . $user->_id . '/add/password'); }
function test_checks_for_access_using_the_access_handler_and_the_gate() { Auth::loginUsingId(1); Gate::define('update-post', function ($user, Post $post) { return $post->id === 1; }); Gate::define('delete-post', function ($user) { return false; }); // Having $items = array('view-post' => [], 'edit-post' => ['allows' => ['update-post', ':post']], 'review-post' => ['denies' => ['update-post', ':post']], 'delete-post' => ['allows' => 'delete-post']); // Expect $this->assertTemplate('menus/access-handler', Menu::make($items)->setParam('post', new Post(1))->render()); }
public function loginAsignado($id, Request $request) { /** * @todo Verificar que el usuario tenga asignada la cuenta de usuario */ if ($request->session()->has('usuarioOriginal')) { $request->session()->forget('usuarioOriginal'); } else { $usaurio_original_id = \Auth::user()->id; $request->session()->put('usuarioOriginal', $usaurio_original_id); } \Auth::loginUsingId($id); return redirect()->back(); }
/** * Registring new user and storing him to DB. * * @return Response */ public function store() { $rules = array('email' => 'required|email|unique:users,email', 'password' => 'required|alpha_num|between:4,50', 'username' => 'required|alpha_num|between:2,20|unique:users,username'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } $user = new User(); $user->email = Input::get('email'); $user->username = Input::get('username'); $user->password = Hash::make(Input::get('password')); $user->save(); Auth::loginUsingId($user->id); return Redirect::home()->with('message', 'Thank you for registration, now you can comment on offers!'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { try { $user = new User(); $user->email = Input::get('email'); $user->password = Hash::make(Input::get('password')); $user->validate()->save(); Auth::loginUsingId($user->id); return $this->respondCreated(['data' => $this->transformer->transform($user)]); } catch (ValidationException $e) { return $this->respondFormValidation($e->getMessage()); } catch (Exception $e) { return $this->respondBadRequest($e->getMessage()); } }
public function postRegister() { $rules = array('email' => 'required|email|unique:users', 'password' => 'required|confirmed'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return array('success' => false, 'errors' => $validator->messages()->toJson()); } else { $user = new User(); $user->password = Hash::make(Input::get('password')); $user->email = Input::get('email'); $user->deposit_btc_address = Bitcoin::createAddress(); $user->save(); Auth::loginUsingId($user->id); return array('success' => true); } }
public function pageFacebook() { $socialize_user = \Socialite::with($provider)->user(); $facebook_user_id = $socialize_user->getId(); // unique facebook user id $user = Contributors::where('facebook_user_id', $facebook_user_id)->first(); // register (if no user) if (!$user) { $user = new Contributors(); $user->facebook_id = $facebook_user_id; $user->save(); } // login Auth::loginUsingId($user->id); return redirect('/'); }
/** * [processSignup description] * @return [type] [description] */ public function processSignup() { $validator = Validator::make(Input::all(), array('email' => 'required|email|unique:users', 'first_name' => 'required|max:40|min:3', 'last_name' => 'required|max:40|min:3', 'password' => 'required|min:6|confirmed', 'screen_name' => 'required|min:5|max:15|unique:users')); if ($validator->fails()) { return $this->backToPreviousRequest($validator->errors()); } $user = new User(); $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); $user->password = Hash::make(Input::get('password')); $user->screen_name = Input::get('screen_name'); $user->email = Input::get('email'); $user->save(); Auth::loginUsingId($user->id); return Redirect::to($this->routeAfterSignup); }
/** * Handle a POST request to reset a user's password. * * @return Response */ public function postReset() { $credentials = \Input::only('email', 'password', 'password_confirmation', 'token'); $response = \Password::reset($credentials, function ($user, $password) { $user->password = \Hash::make($password); $user->save(); \Auth::loginUsingId($user->id); }); switch ($response) { case \Password::INVALID_PASSWORD: case \Password::INVALID_TOKEN: case \Password::INVALID_USER: return \Redirect::back()->with('error', \Lang::get($response)); case \Password::PASSWORD_RESET: return \Redirect::to('/'); } }
public function budgetCharts() { $budgets = Budget::get(); $BC = new BudgetController(); $date = new Carbon('today'); $count = 0; foreach ($budgets as $budget) { Auth::loginUsingId($budget->fireflyuser_id); // remove cached entry: $key = cacheKey('Budget', 'homeOverviewChart', $budget->id, $date); Cache::forget($key); $BC->homeOverviewChart($budget->id, $date); $count++; Auth::logout(); } return 'Regenerated ' . $count . ' budget charts.'; }
public function processlogin() { $rules = array('email' => array('required'), 'password' => array('Required')); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return View::make('users.login_error')->withErrors($validator)->withInput(Input::except('password')); } else { $userdata = array('email' => Input::get('email'), 'password' => Input::get('password')); if (Auth::attempt($userdata)) { $id = Auth::id(); Auth::loginUsingId($id); return Redirect::route('users.index'); } else { return View::make('users.login_error')->withlogin_error('Login credentials incorrect')->withInput(Input::except('password')); } } }