本文整理汇总了PHP中Auth::guest方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::guest方法的具体用法?PHP Auth::guest怎么用?PHP Auth::guest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::guest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLogin
public function getLogin()
{
if (!Auth::guest()) {
return Redirect::action('HomeController@getIndex');
}
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID($_SERVER['HTTP_HOST']);
if (!$openid->mode) {
$openid->identity = 'http://steamcommunity.com/openid';
return Redirect::to($openid->authUrl());
} elseif ($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if ($openid->validate()) {
$id = $openid->identity;
// identity is something like: http://steamcommunity.com/openid/id/76561197994761333
// we only care about the unique account ID at the end of the URL.
$ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
preg_match($ptn, $id, $matches);
$steamid = $matches[1];
$this->fetch_username($steamid);
$this->fetch_backpack($steamid);
Auth::loginUsingId($steamid, true);
return Redirect::action('HomeController@getIndex');
} else {
echo "User is not logged in.\n";
}
}
} catch (ErrorException $e) {
echo $e->getMessage();
}
}
示例2: getIndex
public function getIndex()
{
if (Auth::guest() || Auth::user()->isAdmin == 0) {
return Redirect::secure('/');
}
// layouts variables
$this->layout->title = 'Админ панел | Нещо Шантаво';
$this->layout->canonical = 'https://neshto.shantavo.com/admin/';
$this->layout->robots = 'noindex,nofollow,noodp,noydir';
$users = count(User::all());
$admins = count(User::where('isAdmin', ">", 0)->get());
$categories = count(Category::all());
$albums = count(Album::all());
$votes = count(DB::table('votes')->get());
$pictures = count(Picture::all());
$pictureSize = 0;
foreach (Picture::all() as $p) {
$pictureSize += $p->size;
}
// get disqus stats
include app_path() . '/config/_disqus.php';
$disqus = new DisqusAPI(getDisqusKey());
$disqus->setSecure(false);
$comments = $disqus->posts->list(array('forum' => 'shantavo'));
// nesting the view into the layout
$this->layout->nest('content', 'admin.index', array('users' => $users, 'admins' => $admins, 'votes' => $votes, 'categories' => $categories, 'albums' => $albums, 'pictures' => $pictures, 'pictureSize' => $pictureSize, 'comments' => $comments));
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->is('login') && \Auth::guest()) {
return redirect()->action('LoginController@form');
}
return $next($request);
}
示例4: get_index
function get_index()
{
if (Auth::guest()) {
return View::make('login');
}
return Redirect::to('admin');
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
dd('Unauthorized');
return response('Unauthorized.', 401);
} else {
session_start();
if (isset($_SESSION['cart'])) {
if (\Request::all()) {
array_push($_SESSION['cart'], \Request::all());
}
} else {
$_SESSION['cart'] = [];
array_push($_SESSION['cart'], \Request::all());
}
if (\Auth::guest()) {
\Session::flash('need_to_login_message', 'You need to log in');
}
// dd($_SESSION['cart']);
return redirect()->guest('login');
}
}
return $next($request);
}
示例6: getLogin
/**
* Display the Login Page.
*
* @return Response
*/
public function getLogin()
{
if (Auth::guest()) {
return View::make('auth.login');
}
return Redirect::to('dashboard');
}
示例7: create
public function create()
{
$dc_name = Input::get('dc-name');
$dc_desc = Input::get('dc-desc');
$dc_donation_url = Input::get('dc-donation-url');
$dc_instructions = Input::get('dc-instructions');
if (Auth::guest()) {
/////// Create User of type donationcause_adder
$dcadder_first_name = Input::get('dcadder-first-name');
$dcadder_last_name = Input::get('dcadder-last-name');
$dcadder_mobile = Input::get('dcadder-mobile');
$dcadder_obj = User::createDCAdderAndSave($dcadder_first_name, $dcadder_last_name, $dcadder_mobile);
// =====[start]================================================
// Manually logging in user and 'Remember me' = true.
// So no need to use Auth::attempt
Auth::login($dcadder_obj, true);
// =====[end]================================================
}
if (Auth::guest()) {
dd('why is there no Authenticated User here');
}
if (!Auth::user()->donationcause_adder) {
Auth::user()->makeDonationCauseAdder();
}
// Storing the image
$dc_img_file = Input::file('dc-img-file');
DonationCause::createNewForPosterFromImgFile($dc_name, $dc_desc, $dc_img_file, $dc_donation_url, $dc_instructions, Auth::user()->id);
return Redirect::route('donate');
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->is('auth/login') && \Auth::guest()) {
return redirect('/auth/login');
}
return $next($request);
}
示例9: index
public function index()
{
if (!Auth::guest()) {
return $this->redirectStatus();
}
return View::make('session.login');
}
示例10: addContributor
public function addContributor()
{
$contributor_first_name = Input::get('contributor-first-name');
$contributor_last_name = Input::get('contributor-last-name');
$contributor_mobile = Input::get('contributor-mobile');
$contributor_obj = NULL;
if (Auth::guest()) {
$contributor_obj = User::createContributorAndSave($contributor_first_name, $contributor_last_name, $contributor_mobile);
Auth::login($contributor_obj, true);
} else {
// A user is logged in already. The contributor name and mobile can be same or different
// ONLY checking by mobile right now. TODO : check if this is OK
if ($contributor_mobile != Auth::user()->mobile) {
Log::info("mobile num not equal. MAKE NEW CONTRIB USER !!");
// Using same contributor twice. Or uses existing user as contributor without knowing that they exist on this platform
$contributor_obj = User::createContributorIfNotExists($contributor_first_name, $contributor_last_name, $contributor_mobile);
} else {
Log::info("mobile num equal. Auth is Contributor !! ");
$contributor_obj = Auth::user();
$contributor_obj->makeContributor();
}
}
$au_file = Input::file('au-file');
$upload_number = Auth::user()->incrementUploadNumber();
$new_file_name = $contributor_first_name . $contributor_mobile . '_uploaded_by_' . Auth::user()->fname . $upload_number . '.csv';
$new_file_location = app_path() . '/database/seedAfterReview/';
$au_file->move($new_file_location, $new_file_name);
// I will review. No automatic upload
//$file_full_path = $new_file_location . $new_file_name;
//Helper::createArmyUpdatesFromFileForContributor($file_full_path, $contributor_obj->id);
return Redirect::to('dashboard');
}
示例11: _isUnread
private function _isUnread()
{
if (Auth::guest()) {
return false;
}
$markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after'));
if (!IoC::registered('topicsview')) {
IoC::singleton('topicsview', function () use($markAsReadAfter) {
return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id');
});
}
$tv = IoC::resolve('topicsview');
$nb = count($tv);
$view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter));
if ($nb > 0) {
$view = $view->where_not_in('id', $tv);
}
$view = $view->count();
if ($nb == 0 && $view > 0) {
return true;
}
if ($view > 0) {
return true;
}
return false;
}
示例12: bootCreation
/**
* Boot the creation trait for a model.
*
* @return void
*/
public static function bootCreation()
{
// create a event to happen on deleting
static::deleting(function ($table) {
if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
$table->deleted_by = Sentinel::getUser()->id;
} else {
$table->deleted_by = Auth::user()->id;
}
$table->update(['deleted_by' => $table->deleted_by]);
});
// create a event to happen on saving
static::saving(function ($table) {
if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
if (Sentinel::check()) {
$table->modified_by = Sentinel::getUser()->id;
}
if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) {
$table->created_by = Sentinel::getUser()->id;
}
} else {
if (!Auth::guest()) {
$table->modified_by = Auth::user()->id;
}
if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) {
$table->created_by = Auth::user()->id;
}
}
});
}
示例13: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (\Auth::guest()) {
return redirect('auth/login');
}
return view('admin/register');
}
示例14: handleNotFound
public function handleNotFound()
{
if (\Auth::guest()) {
return redirect('/auth/login');
}
return response(view('index')->render());
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::guest()) {
return redirect('/login');
}
return $next($request);
}