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


PHP Auth::User方法代码示例

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


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

示例1: beforeSave

 /**
  * Checks if the product is new, and sets the created and modified times appropriately,
  * prior to saving.
  * @see testProjectModel::beforeSave()
  */
 public function beforeSave()
 {
     if ($this->isNew) {
         $this->created = date("Y-m-d H:i:s");
         $this->modified = $this->created;
         $this->user = Auth::User()->id;
     } else {
         $this->modified = date("Y-m-d H:i:s");
     }
     $tags = isset($this->attributes['tags']) ? $this->attributes['tags'] : array();
     foreach ($tags as $i => $tag) {
         if (!is_numeric($tag)) {
             $tagModel = new tags(array('name' => $tag));
             $tagModel->save();
             $tags[$i] = $tagModel->id;
         } else {
             $tags[$i] = intval($tag);
         }
     }
     $this->tagIds = $tags;
     unset($this->attributes['tags']);
     if (!is_numeric($this->vendor)) {
         $vendor = new vendors(array('name' => $this->vendor));
         $vendor->save();
         $this->vendor = $vendor->id;
     }
     $this->cleanDates(array('purchaseDate', 'saleDate', 'soldDate'));
     return true;
 }
开发者ID:amarble,项目名称:project-byz,代码行数:34,代码来源:items.php

示例2: postSignIn

 public function postSignIn()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     $remember = Input::get('remember_me');
     $validation = new SeatUserValidator();
     if ($validation->passes()) {
         // Check if we got a username or email for auth
         $identifier = filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
         // Attempt authentication using a email address
         if (Auth::attempt(array($identifier => $email, 'password' => $password), $remember ? true : false)) {
             // If authentication passed, check out if the
             // account is activated. If it is not, we
             // just logout again.
             if (Auth::User()->activated) {
                 return Redirect::back()->withInput();
             } else {
                 // Inactive account means we will not keep this session
                 // logged in.
                 Auth::logout();
                 // Return the session back with the error. We are ok with
                 // revealing that the account is not active as the
                 // credentials were correct.
                 return Redirect::back()->withInput()->withErrors('This account is not active. Please ensure that you clicked the activation link in the registration email.
                     ');
             }
         } else {
             return Redirect::back()->withErrors('Authentication failure');
         }
     }
     return Redirect::back()->withErrors($validation->errors);
 }
开发者ID:boweiliu,项目名称:seat,代码行数:32,代码来源:SessionController.php

示例3: doLogin

 /**
  *   Función responsable de autenticar a un usuario en la aplicación
  */
 public function doLogin()
 {
     $response = null;
     try {
         // Se validan las credenciales.
         $validator = $this->validateCredentials();
         if ($validator->passes()) {
             $remember = false;
             // por defecto no recuerda el usuario autenticado.
             $credentials = $this->getLoginCredentials();
             // se verifica si el usuario fue autenticado
             if (Auth::attempt($credentials, $remember)) {
                 // se retorna la información del usuario cuando este es autenticado.
                 $response = $this->respondWithItem(Auth::User(), new UserTransformer());
             } else {
                 $response = $this->respondWithError(self::MESSAGE_COULD_NOT_AUTHENTICATE, self::CODE_COULD_NOT_AUTHENTICATE);
             }
         } else {
             $response = $this->respondWithError($validator->messages(), self::CODE_WRONG_ARGUMENTS);
         }
     } catch (Exception $e) {
         $response = $this->errorInternalError($e->getMessage());
     }
     return $response;
 }
开发者ID:jhoansebastianlara,项目名称:esclinicadigital,代码行数:28,代码来源:AuthController.php

示例4: logoutAction

 public function logoutAction()
 {
     // Log out
     if (Auth::User()) {
         $user = new Usernhc();
         $user_id = Auth::User()->id;
         $user_info = $user->getUsernhcById($user_id);
         $logs = new Logs();
         $logs->ip = Request::getClientIp();
         $logs->host = Request::root();
         $logs->lastpage = '';
         $logs->last_visit = date('Y-m-d H:i:s');
         $logs->role_id = $user_info[0]->role_id;
         $logs->data_id = rand(1, 11);
         $logs->userid = $user_id;
         $logs->save();
     }
     // Redirect to homepage
     if (Auth::logout()) {
         Auth::logout();
         return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ');
     } else {
         return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ');
     }
 }
开发者ID:nattaphat,项目名称:cuse2,代码行数:25,代码来源:AuthController.php

示例5: guardarPerfil

 public function guardarPerfil()
 {
     //Campos
     $nombresApellidos = e(Input::get('nombresApellidos'));
     $telefono = e(Input::get('telefono'));
     $edad = e(Input::get('edad'));
     $correo = e(Input::get('correo'));
     $genero = e(Input::get('genero'));
     //Reglas
     $rules = array('nombresApellidos' => 'required|regex:/^([a-zA-z])/', 'edad' => 'regex:/^([0-9])/', 'telefono' => 'regex:/^([0-9])/', 'correo' => 'regex:/^([a-zA-Z0-9])+@espoch.edu.ec/', 'genero' => 'in:Masculino,Femenino');
     //Mensajes
     $messages = array('required' => 'El campo :attribute es obligatorio', 'correo' => 'El campo :attribute debe ser un email institucional', 'in' => 'Seleccione una opción válida', 'unique' => 'El correo electrónico ya fue registrado');
     $validation = Validator::make(Input::all(), $rules, $messages);
     if ($validation->fails()) {
         return Redirect::to(URL::previous())->withInput()->withErrors($validation);
     } else {
         $usuario = User::find(Auth::User()->id);
         $usuario->nombres_usuario = $nombresApellidos;
         $usuario->telefono_usuario = $telefono;
         $usuario->edad_usuario = $edad;
         $usuario->correo_usuario = $correo;
         $usuario->genero_usuario = $genero;
         $usuario->save();
         return Redirect::to(URL::previous())->with('mensaje', 'Perfil Actualizado Corrrectamente');
     }
 }
开发者ID:cristianeto,项目名称:PortalCimogsys,代码行数:26,代码来源:UserController.php

示例6: update

 public function update($id)
 {
     if (Auth::id() != $id) {
         return Redirect::to('http://google.com');
     }
     $user = Auth::User();
     $validator = Validator::make(Input::all(false), ['email' => 'required|email|unique:users,email,' . $id, 'password' => 'min:5|confirmed:password_confirmation', 'first_name' => 'required', 'last_name' => 'required']);
     if ($validator->passes()) {
         $img_ava = $user->avatar_img;
         $password = Input::get('password');
         if (Input::hasFile('avatar_img')) {
             if (File::exists(Config::get('user.upload_user_ava_directory') . $img_ava)) {
                 File::delete(Config::get('user.upload_user_ava_directory') . $img_ava);
             }
             if (!is_dir(Config::get('user.upload_user_ava_directory'))) {
                 File::makeDirectory(Config::get('user.upload_user_ava_directory'), 0755, true);
             }
             $img = Image::make(Input::file('avatar_img'));
             $img_ava = md5(Input::get('username')) . '.' . Input::file('avatar_img')->getClientOriginalExtension();
             if ($img->width() < $img->height()) {
                 $img->resize(100, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             } else {
                 $img->resize(null, 100, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             }
         }
         $user->update(['username' => null, 'email' => Input::get('email'), 'password' => !empty($password) ? Hash::make($password) : $user->password, 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]);
         return Redirect::back()->with('success_msg', Lang::get('messages.successupdate'));
     } else {
         return Redirect::back()->withErrors($validator)->withInput();
     }
 }
开发者ID:rezadaulay,项目名称:bankupu,代码行数:35,代码来源:SessionController.php

示例7: log

 public static function log($action, $userid = null)
 {
     if ($userid == null) {
         $userid = Auth::User()->id;
     }
     DB::table('logs')->insert(array('logs_action' => $action, 'logs_userId' => $userid, 'logs_ip' => $_SERVER["HTTP_CF_CONNECTING_IP"]));
 }
开发者ID:G4brym,项目名称:ServerList.pt,代码行数:7,代码来源:utilities.php

示例8: SISA_index

 public function SISA_index()
 {
     $rol = Auth::User()->Rol_Id;
     switch ($rol) {
         case 1:
             Session::put('admninistrador', Auth::user());
             return Redirect::to('/dsbd');
             break;
         case 2:
             Session::put('oficialia', Auth::user());
             return Redirect::to('/oficialia');
             break;
         case 3:
             Session::put('direccion', Auth::user());
             return Redirect::to('/direccion');
             break;
         case 4:
             Session::put('subdireccion', Auth::user());
             return Redirect::to('/subdireccion');
             break;
         case 5:
             Session::put('jefatura', Auth::user());
             return Redirect::to('/jefatura');
             break;
         case 6:
             Session::put('iescmpl', Auth::user());
             return Redirect::to('/iescmpl');
             break;
         default:
             return Redirect::to('/login');
             break;
     }
 }
开发者ID:jonatanian,项目名称:TT,代码行数:33,代码来源:LoginController.php

示例9: logout

 public function logout()
 {
     $user = Auth::User();
     $users = $user['u_name'];
     Auth::logout();
     return Redirect::to('index')->with('out', "Goodbye,  Welcome Back again!!!!!!  " . $users . "  ");
 }
开发者ID:KornelMbele,项目名称:ResultSystem,代码行数:7,代码来源:UserLoginController.php

示例10: index

 public function index()
 {
     $notifications = Notification::where('user', '=', Auth::User()->id)->orderBy('id', 'desc')->take(5)->get();
     $count_notification = Notification::where('user', '=', Auth::User()->id)->where('read', '=', 0)->count();
     $user_details = array('surname' => Auth::User()->surname, 'name' => Auth::User()->name, 'avatar' => Auth::User()->avatar);
     $sidebar_adverts = DB::table('adverts')->join('advertisers', 'advertisers.id', '=', 'adverts.advertiser')->where('advertisers.id', '=', Auth::User()->advertiser)->select('adverts.name')->get();
     return View::make('profile')->with('user', $user_details)->with('notifications', $notifications)->with('sidebar_adverts', $sidebar_adverts)->with('count_notification', $count_notification);
 }
开发者ID:RPupaza,项目名称:dashboard,代码行数:8,代码来源:ProfileController.php

示例11: getDelete

 public function getDelete($exerciseID)
 {
     $exercise = \App\Exercise::find($exerciseID);
     if ($exercise && $exercise->user_id == \Auth::User()->id) {
         $exercise->delete();
     }
     return redirect('/user/workouts/exercises');
 }
开发者ID:spitzgoby,项目名称:dwa15_p4,代码行数:8,代码来源:ExerciseController.php

示例12: getLogout

 /**
  * do Logout process.
  *
  * @return Response
  */
 public function getLogout()
 {
     if (Auth::User()) {
         Auth::logout();
         return Redirect::to($this->loginURL)->with('message', 'User logged out.');
     } else {
         return Redirect::to($this->loginURL)->with('message', 'User not found or password incorrect.');
     }
 }
开发者ID:sdbruder,项目名称:laravel42testapp,代码行数:14,代码来源:AuthController.php

示例13: isFavored

 public function isFavored()
 {
     if (!Auth::check()) {
         return false;
     }
     if ($this->belongsToMany('User', 'favorites', 'quote_id', 'user_id')->whereUserId(Auth::User()->id)->count() > 0) {
         return true;
     }
 }
开发者ID:shiftosnext,项目名称:Quotinator,代码行数:9,代码来源:Quote.php

示例14: logout

 public function logout()
 {
     $id = Auth::User()->id;
     $user = User::find($id);
     $user->estado_usuario = 0;
     $user->save();
     Auth::logout();
     return Redirect::to('/');
 }
开发者ID:cristianeto,项目名称:PortalCimogsys,代码行数:9,代码来源:AuthController.php

示例15: showMCServer

 public function showMCServer($id)
 {
     if (count(DB::table('mcservers')->where('mcs_id', '=', $id)->where('mcs_uid', '=', Auth::User()->id)->first())) {
         $title = settings::get("siteName") . " - Servidor De Minecraft";
         return View::make('panel.MCServer')->with('title', $title)->with('id', $id);
     } else {
         return Redirect::to(URL::to('/panel/servers'));
     }
 }
开发者ID:G4brym,项目名称:ServerList.pt,代码行数:9,代码来源:PanelController.php


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