当前位置: 首页>>代码示例>>PHP>>正文


PHP Sentry::getUser方法代码示例

本文整理汇总了PHP中Sentry::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::getUser方法的具体用法?PHP Sentry::getUser怎么用?PHP Sentry::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentry的用法示例。


在下文中一共展示了Sentry::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $this->loginForm->validate($input = Input::only('email', 'password'));
     try {
         Sentry::authenticate($input, true);
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.mgs_invalid_credential'), 'url' => '');
         return Response::json($mjs);
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.user_not_activated'), 'url' => '');
         return Response::json($mjs);
     } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $mjs = array('success' => false, 'mgs' => trans('main.user_suspended'), 'url' => '');
         return Response::json($mjs);
     }
     // Logged in successfully - redirect based on type of user
     $user = Sentry::getUser();
     $admin = Sentry::findGroupByName('Admins');
     $users = Sentry::findGroupByName('Patients');
     $doctors = Sentry::findGroupByName('Doctors');
     $company = Sentry::findGroupByName('Clinics');
     $recepcion = Sentry::findGroupByName('Receptionist');
     if ($user->inGroup($admin)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/admin');
         return Response::json($mjs);
     } elseif ($user->inGroup($company) or $user->inGroup($recepcion)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/clinic');
         return Response::json($mjs);
     } elseif ($user->inGroup($doctors)) {
         $mjs = array('success' => true, 'mgs' => trans('main.mgs_access'), 'url' => url() . '/doctor');
         return Response::json($mjs);
     } elseif ($user->inGroup($users)) {
         return Redirect::to(url());
     }
 }
开发者ID:jnicolasbc,项目名称:admin_swp_com,代码行数:40,代码来源:SessionsController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  * POST /sessions/store.
  *
  * @return Response
  */
 public function store()
 {
     // Set login credentials
     $input = array('email' => Input::get('email'), 'password' => Input::get('password'));
     // Try to authenticate the user
     try {
         Sentry::authenticate($input, Input::has('remember'));
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->withInput()->withErrorMessage('Invalid credentials provided');
     } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Redirect::back()->withInput()->withErrorMessage('User Not Activated.');
     }
     // Logged in successfully - redirect based on type of user
     $user = Sentry::getUser();
     $adminsGroup = Sentry::findGroupByName('Admins');
     $usersGroup = Sentry::findGroupByName('Users');
     if ($user->inGroup($adminsGroup)) {
         return Redirect::intended('admin');
     } elseif ($user->inGroup($usersGroup)) {
         if (!stripos(Session::get('url.intended', '/'), '/admin')) {
             return Redirect::intended('/');
         } else {
             return Redirect::to('/');
         }
     }
 }
开发者ID:despark,项目名称:laravel-project-starter,代码行数:32,代码来源:SessionsController.php

示例3: refunds

 public function refunds()
 {
     $properties = Property::where('agent_id', '=', Sentry::getUser()->id)->get();
     $refunds = Invoice::where('type', '=', 'refund')->get();
     $amountpaid = 0;
     return View::make('backend.code.invoice.refunds', compact('refunds', 'amountpaid', 'properties'));
 }
开发者ID:jeremiteki,项目名称:mteja-laravel,代码行数:7,代码来源:HousController.php

示例4: isCurrent

 public function isCurrent()
 {
     if (!Sentry::check()) {
         return false;
     }
     return Sentry::getUser()->id == $this->id;
 }
开发者ID:ArbindJain,项目名称:basic-auth-sentry,代码行数:7,代码来源:User.php

示例5: add_feedback

 public function add_feedback()
 {
     $type = Input::get('type');
     $title = Input::get('title');
     $content = Input::get('content');
     if (!isset($type)) {
         return Response::json(array('errCode' => 1, 'message' => '请选者反馈类型'));
     }
     if (!isset($title)) {
         return Response::json(array('errCode' => 2, 'message' => '请输入标题'));
     }
     if (!isset($content)) {
         return Response::json(array('errCode' => 3, 'message' => '请输入内容'));
     }
     $feedback = new Feedback();
     $feedback->user_id = Sentry::getUser()->user_id;
     $feedback->type = $type;
     $feedback->title = $title;
     $feedback->content = $content;
     $feedback->status = 0;
     if (!$feedback->save()) {
         return Response::json(array('errCode' => 4, 'message' => '保存失败'));
     }
     return Response::json(array('errCode' => 0, 'message' => '保存成功'));
 }
开发者ID:Jv-Juven,项目名称:carService,代码行数:25,代码来源:FeedbackController.php

示例6: __construct

 public function __construct()
 {
     if (Sentry::check()) {
         // User is not logged in, or is not activated
         $this->data['admin'] = Sentry::getUser();
     }
 }
开发者ID:jacobDaeHyung,项目名称:PHPLaravelGymManagementSystem,代码行数:7,代码来源:BaseController.php

示例7: postReply

 public function postReply()
 {
     try {
         $board_id = Arr::get($_POST, 'board_id', null);
         $labels = Arr::get($_POST, 'labels', array());
         $content = Arr::get($_POST, 'content', '');
         if ($board_id === null || empty($content)) {
             throw new Exception('回覆失敗');
         }
         $br = new BoardReply();
         $br->tags = serialize($labels);
         $br->content = $content;
         $br->creator = Sentry::getUser()->getId();
         $br->created_at = date('Y-m-d H:i:s');
         $br->board_id = $board_id;
         $br->save();
         //update status of board
         $b = Board::find($board_id);
         $b->isReply = '1';
         $b->save();
         return Redirect::route('admin.board.list');
     } catch (Exception $e) {
         return Redirect::back()->withInput()->withErrors($e->getMessage());
     }
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:25,代码来源:BoardController.php

示例8: 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' => '开启消息推送'));
     }
 }
开发者ID:Jv-Juven,项目名称:gift,代码行数:33,代码来源:SiteController.php

示例9: postLogin

 /**
  * AdminUserController::postLogin()
  *
  * @return
  */
 public function postLogin()
 {
     $userService = new UserAccountService();
     $rules = array('email' => 'Required|email', 'password' => 'Required');
     $validator = \Validator::make(\Input::all(), $rules);
     if (!$validator->fails()) {
         $user = array('email' => \Input::get('email'), 'password' => \Input::get('password'));
         $remember = \Input::get('remember');
         $error = $userService->doLogin($user, $remember);
         if ($error == '') {
             $redirect = '';
             if (\Sentry::getUser()->hasAnyAccess(['system'])) {
                 $redirect = \Config::get('webshopauthenticate::admin_uri');
             } else {
                 $redirect = \Config::get('webshopauthenticate::uri') . '/myaccount';
             }
             return \Redirect::intended($redirect);
         }
         $error_msg = '';
         if ($error == 'Invalid') {
             $error_msg = \Lang::get('webshopauthenticate::auth/form.login.invalid_login');
         } else {
             if ($error == 'ToActivate') {
                 $error_msg = \Lang::get('webshopauthenticate::auth/form.login.account_not_confirmed');
             }
         }
         \Session::flash('error', $error_msg);
         return \Redirect::to(\Config::get('webshopauthenticate::uri') . '/login')->withInput();
     } else {
         return \Redirect::to(\Config::get('webshopauthenticate::uri') . '/login')->withErrors($validator->messages())->withInput();
     }
 }
开发者ID:ahsanpackage,项目名称:webshopauthenticate,代码行数:37,代码来源:AuthController.php

示例10: settings

 public function settings()
 {
     $user = Sentry::getUser();
     if (Input::get('email') == $user->email) {
         $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
     } else {
         $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json($validator->messages());
     } else {
         $setting = Setting::first();
         $setting->sitename = Input::get('sitename');
         $setting->save();
         $user = User::find($user->id);
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->email = Input::get('email');
         $user->password = Input::get('password');
         $user->save();
         $feedback = array('success' => 'Settings successfully saved.');
         return Response::json($feedback);
     }
 }
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:25,代码来源:SettingController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Fetch all request data.
     $data = Input::only('title', 'extra_url', 'event_id');
     $event_id = Input::get('event_id');
     // Build the validation constraint set.
     $rules = array('title' => array('required', 'min:3'), 'extra_url' => array('required', 'Url'), 'event_id' => array('required', 'integer', 'sometimes'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $extra = new Extra();
         $current_user = Sentry::getUser();
         if ($current_user->hasAccess('admin') || $current_user->hasAccess('verified')) {
             $extra->approved = '1';
         }
         $extra->author_id = Sentry::getUser()->id;
         $extra->title = Input::get('title');
         $extra->extra_url = Input::get('extra_url');
         $extra->save();
         $event = ep\Event::find($event_id);
         $event->eventExtra()->save($extra);
         return Redirect::to('/event/' . $event->slug)->with('global_success', 'Event submitted successfuly!');
     }
     return Redirect::to('/event/' . $event->slug)->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:30,代码来源:ExtraController.php

示例12: 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);
 }
开发者ID:nozkok,项目名称:laravel-4-starter,代码行数:35,代码来源:BlogController.php

示例13: requestRefund

 public function requestRefund()
 {
     $order_id = Input::get('order_id');
     $order = AgencyOrder::find($order_id);
     if (!isset($order)) {
         return Response::json(array('errCode' => 21, 'message' => '该订单不存在'));
     }
     $refund_record = RefundRecord::where('order_id', '=', $order_id)->get();
     if (count($refund_record) != 0) {
         return Response::json(array('errCode' => 22, 'message' => '申请已提交'));
     }
     if ($order->trade_status != 1 || $order->process_status != 1) {
         return Response::json(array('errCode' => 23, 'message' => '该订单不可申请退款'));
     }
     try {
         DB::transaction(function () use($order) {
             $order->trade_status = 2;
             $order->save();
             $refund_record = new RefundRecord();
             $refund_record->order_id = $order->order_id;
             $refund_record->user_id = Sentry::getUser()->user_id;
             $refund_record->save();
         });
     } catch (Exception $e) {
         return Response::json(array('errCode' => 24, 'message' => '退款申请失败,请重新申请'));
     }
     return Response::json(array('errCode' => 0, 'message' => '申请成功'));
 }
开发者ID:Jv-Juven,项目名称:carService,代码行数:28,代码来源:OrderController.php

示例14: execute

 public function execute($function)
 {
     if (Sentry::check() && Sentry::getUser()->isSuperUser()) {
         return $function();
     }
     return 'You have no privileges to access this page!';
 }
开发者ID:shaikhatik0786,项目名称:Masteranime,代码行数:7,代码来源:AnimeManageController.php

示例15: 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.');
 }
开发者ID:forestallers,项目名称:laravel-starter-kit,代码行数:35,代码来源:BlogController.php


注:本文中的Sentry::getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。