本文整理汇总了PHP中Sentry::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::check方法的具体用法?PHP Sentry::check怎么用?PHP Sentry::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reset
public function reset($id)
{
if (Sentry::check()) {
return Redirect::route('admin.dashboard');
}
return View::make('administrator.reset', ['title' => 'Nueva Contraseña', 'data' => $id]);
}
示例2: postView
/**
* View a blog post.
*
* @param string $slug
* @return Redirect
*/
public function postView($slug)
{
// The user needs to be logged in, make that check please
if (!Sentry::check()) {
return Redirect::to("blog/{$slug}#comments")->with('error', 'You need to be logged in to post comments!');
}
// Get this blog post data
$post = Post::where('slug', $slug)->first();
// Declare the rules for the form validation
$rules = array('comment' => 'required|min:3');
// Create a new validator instance from our dynamic rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now
if ($validator->fails()) {
// Redirect to this blog post page
return Redirect::to("blog/{$slug}#comments")->withInput()->withErrors($validator);
}
// Save the comment
$comment = new Comment();
$comment->user_id = Sentry::getUser()->id;
$comment->content = e(Input::get('comment'));
// Was the comment saved with success?
if ($post->comments()->save($comment)) {
// Redirect to this blog post page
return Redirect::to("blog/{$slug}#comments")->with('success', 'Your comment was successfully added.');
}
// Redirect to this blog post page
return Redirect::to("blog/{$slug}#comments")->with('error', 'There was a problem adding your comment, please try again.');
}
示例3: before
public function before()
{
$this->nocversion = 'none';
$path = $this->request->route->path;
if ($path != 'auth/login') {
$this->check_license($path);
}
parent::before();
//$auth = Auth::instance();
//Auth::instance()->login('hrvoje','hajduk81');
/*
if(!$this->check_license())
\Response::redirect(\Config::get('base_url').'/ajax/license');
*/
$uri_string = explode('/', Uri::string());
if (count($uri_string) > 1 and $uri_string[0] == 'auth' and $uri_string[1] == 'login') {
return;
}
if ($path != '_root_') {
if (\Sentry::check()) {
$this->user = Sentry::user()->get('id');
$this->username = Sentry::user()->get('username');
return;
} else {
$this->user = false;
$this->username = '';
\Response::redirect(\Config::get('base_url') . 'auth/login');
}
}
}
示例4: postView
/**
* View a blog post.
*
* @param string $slug
* @return Redirect
*/
public function postView($slug)
{
// The user needs to be logged in, make that check please.
if (!Sentry::check()) {
return Redirect::to($slug . '#comments')->with('error', 'You need to be logged in to post comments!');
}
// Get this blog post data
$post = Post::where('slug', '=', $slug)->first();
// Declare the rules for the form validation
$rules = array('comment' => 'required|min:3');
// Validate the inputs
$validator = Validator::make(Input::all(), $rules);
// Check if the form validates with success
if ($validator->passes()) {
// Save the comment
$comment = new Comment();
$comment->user_id = Sentry::getUser()->id;
$comment->content = Input::get('comment');
// Was the comment saved with success?
if ($post->comments()->save($comment)) {
// Redirect to this blog post page
return Redirect::to($slug . '#comments')->with('success', 'Your comment was added with success.');
}
// Redirect to this blog post page
return Redirect::to($slug . '#comments')->with('error', 'There was a problem adding your comment, please try again.');
}
// Redirect to this blog post page
return Redirect::to($slug)->withInput()->withErrors($validator);
}
示例5: postView
/**
* View a blog post.
*
* @param string $slug
* @return Redirect
*/
public function postView($slug)
{
// The user needs to be logged in, make that check please
if (!Sentry::check()) {
return Redirect::to("blog/{$slug}#comments")->with('error', Lang::get('post.messages.login'));
}
// Get this blog post data
$post = $this->post->where('slug', $slug)->first();
// get the data
$new = Input::all();
$comment = new Comment();
// If validation fails, we'll exit the operation now
if ($comment->validate($new)) {
// Save the comment
$comment->user_id = Sentry::getUser()->id;
$comment->content = e(Input::get('comment'));
// Was the comment saved with success?
if ($post->comments()->save($comment)) {
// Redirect to this blog post page
return Redirect::to("blog/{$slug}#comments")->with('success', 'Your comment was successfully added.');
}
} else {
// failure, get errors
return Redirect::to("blog/{$slug}#comments")->withInput()->withErrors($comment->errors());
}
// Redirect to this blog post page
return Redirect::to("blog/{$slug}#comments")->with('error', Lang::get('post.messages.generic'));
}
示例6: showLogin
public function showLogin()
{
if (Sentry::check()) {
return Redirect::to('/admin');
}
return View::make('admin::vis-login');
}
示例7: check
public function check()
{
if (!Sentry::check()) {
$this->layout = null;
return Redirect::action('HomeController@index')->with('message', "<div class='alert alert-danger'>You don't have access to this page.</div>");
}
}
示例8: getDefault
/**
* Handles GET requests from /
*
* @return view
*/
public function getDefault()
{
if (Sentry::check()) {
return Redirect::to('dashboard');
}
return View::make('layouts.default');
}
示例9: isCurrent
public function isCurrent()
{
if (!Sentry::check()) {
return false;
}
return Sentry::getUser()->id == $this->id;
}
示例10: showLogin
public function showLogin()
{
if (\Sentry::check()) {
return \Redirect::to(\Config::get('jarboe::admin.uri'));
}
return \View::make('admin::vis-login');
}
示例11: getLogin
/**
* Display the login page
* @return View
*/
public function getLogin()
{
if (Sentry::check()) {
return Redirect::route('admin.index');
}
return View::make('admin.auth.login');
}
示例12: __construct
public function __construct()
{
if (Sentry::check()) {
// User is not logged in, or is not activated
$this->data['admin'] = Sentry::getUser();
}
}
示例13: getLogout
public function getLogout()
{
if (Sentry::check()) {
Sentry::logout();
return Redirect::route('index');
}
}
示例14: execute
public function execute($function)
{
if (Sentry::check() && Sentry::getUser()->isSuperUser()) {
return $function();
}
return 'You have no privileges to access this page!';
}
示例15: pushMessage
public function pushMessage()
{
if (!Sentry::check()) {
return Response::json(array('errCode' => 10, 'message' => '请登录'));
}
Sentry::login(Sentry::findUserById(5), false);
$user = Sentry::getUser();
// $user = User::find(1);
$push_status = PushStatus::where('user_id', $user->id)->first();
if (count($push_status) == 0) {
$push_status = new PushStatus();
$push_status->user_id = $user->id;
$push_status->status = 1;
if (!$push_status->save()) {
return Response::json(array('errCode' => 1, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
if ($push_status->status == 1) {
$push_status->status = 0;
if (!$push_status->save()) {
return Response::json(array('errCode' => 2, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
if ($push_status->status == 0) {
$push_status->status = 1;
if (!$push_status->save()) {
return Response::json(array('errCode' => 3, 'message' => '[数据库错误]开启消息推送失败'));
}
return Response::json(array('errCode' => 0, 'message' => '开启消息推送'));
}
}