本文整理汇总了PHP中Illuminate\Support\Facades\Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Auth类的具体用法?PHP Auth怎么用?PHP Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Closure|\Closure $next
* @param $permissions
* @return mixed
* @internal param $roles
* @internal param null|string $guard
*/
public function handle(Request $request, Closure $next, $permissions)
{
if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
abort(403);
}
return $next($request);
}
开发者ID:Matth--,项目名称:privileges,代码行数:17,代码来源:PrivilegesPermissionMiddleware.php
示例2: slots
public function slots()
{
$user = Auth::user();
$location = $user->location;
$slot = Slot::where('location', '=', $location)->first();
$input = Input::get('wager');
$owner = User::where('name', '=', $slot->owner)->first();
$num1 = rand(1, 10);
$num2 = rand(5, 7);
$num3 = rand(5, 7);
if ($user->name != $owner->name) {
if ($num1 & $num2 & $num3 == 6) {
$money = rand(250, 300);
$payment = $money += $input * 1.75;
$user->money += $payment;
$user->save();
session()->flash('flash_message', 'You rolled three sixes!!');
return redirect('/home');
} else {
$user->money -= $input;
$user->save();
$owner->money += $input;
$owner->save();
session()->flash('flash_message_important', 'You failed to roll three sixes!!');
return redirect(action('SlotsController@show', [$slot->location]));
}
} else {
session()->flash('flash_message_important', 'You own this slot!!');
return redirect(action('SlotsController@show', [$slot->location]));
}
}
开发者ID:mathewsandi,项目名称:MafiaGame,代码行数:31,代码来源:SlotsController.php
示例3: store
public function store()
{
$this->record = new Activity(array_merge(Request::all(), ['adder_id' => Auth::User()->id, 'modifier_id' => Auth::User()->id]));
try {
switch ($this->related_type) {
case 'lead':
$this->relatedObj = new \App\Lead();
break;
case 'contact':
$this->relatedObj = new \App\Contact();
break;
case 'account':
$this->relatedObj = new \App\Account();
break;
case 'opportunity':
$this->relatedObj = new \App\Opportunity();
break;
default:
}
$obj = $this->relatedObj->find($this->related_id);
if ($this->validated()) {
$obj->activities()->save($this->record);
}
} catch (\Exception $e) {
Session::flash('pageError', 'Error saving activity.' . $e->getMessage());
return View('activity/activity-new', ['record' => $this->record, 'relates_to' => $this->relates_to]);
}
$redirectURL = Request::input('action') == 'saveNew' ? '/activity/create?related_type=' . $this->related_type . '&related_id=' . $this->related_id : '/' . $this->related_type . '/' . $this->related_id;
return redirect($redirectURL)->with('pageSuccess', 'Activity saved successfully.');
}
开发者ID:reimo,项目名称:crm-laravel,代码行数:30,代码来源:ActivityController.php
示例4: store
/**
* Store a newly created resource in storage.
*
* @param AdduserRequest $request
* @return \Illuminate\Http\Response
*/
public function store(AdduserRequest $request)
{
// $input = $request->all(); // get all data
// $input['confirmed'] = 1; // set confirmed to 1
// $input['password'] = Hash::make($input['password']); // hash password
//
// $user = User::create($input); // save above details
$user = User::create(['first_name' => $request->first_name, 'last_name' => $request->last_name, 'email' => $request->email, 'confirmed' => 1, 'password' => Hash::make($request->password)]);
// $profile = $user->profile()->save(new Profile); // also create new profile
// $profile->apartment_id = Auth::user()->profile->defaultApartment; // get current defaultApartment
// $profile->save(); // save details on profile
$profile = Profile::create(['user_id' => $user->id, 'apartment_id' => Auth::user()->profile->defaultApartment]);
dd(Auth::user()->profile->defaultApartment);
$role = Role::whereName('user')->first();
$user->assignRole($role);
//Assign Role
$block_no = $request->blockno;
// get block_no from profileform
$floor_no = $request->floorno;
// get floor_no from profileform
$profile->apartments()->attach($profile->defaultApartment, ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no]);
// attach this profile with default apartment, with approved = 1, and block_no, floor_no according to profileform in apartment_profile pivot table.
Crm_account::create(['account' => $user->first_name . $user->last_name, 'fname' => $user->first_name, 'lname' => $user->last_name, 'company' => 'Company Name', 'email' => $user->email, 'address' => 'Current Address', 'city' => 'Nagpur', 'state' => 'Maharashtra', 'zip' => '440012', 'country' => 'India']);
return redirect()->back()->withMessage('User has been Added')->withStatus('success');
}
开发者ID:suchayj,项目名称:easymanage,代码行数:31,代码来源:AdduserController.php
示例5: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$validation['password'] = 'required|min:6|confirmed';
$validation['current_password'] = 'required';
$user = Auth::user();
return $validation;
}
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:12,代码来源:ChangePasswordRequest.php
示例6: update
public function update()
{
$profile = Profile::where('user_id', Auth::user()->id)->first();
$profile->fill(Input::all());
$profile->save();
return Redirect::to("/edit_profile");
}
开发者ID:Volkan61,项目名称:begreat,代码行数:7,代码来源:ProfileController.php
示例7: validate
/**
* @param $credentials
* @throws ValidationFailed
*/
public function validate($credentials)
{
$valid = Auth::validate($credentials);
if (!$valid) {
throw new ValidationFailed();
}
}
开发者ID:RobbieBakker,项目名称:laravelstuff,代码行数:11,代码来源:User.php
示例8: boot
/**
* Boot Oci8 Provider
*/
public function boot()
{
$this->publishes([__DIR__ . '/../config/oracle.php' => config_path('oracle.php')], 'oracle');
Auth::provider('oracle', function ($app, array $config) {
return new OracleUserProvider($app['hash'], $config['model']);
});
}
开发者ID:yajra,项目名称:laravel-oci8,代码行数:10,代码来源:Oci8ServiceProvider.php
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::check() || !Auth::user()->admPower) {
return redirect()->route('paginaInicial');
}
return $next($request);
}
开发者ID:EJCM,项目名称:rodalol,代码行数:14,代码来源:AdminMiddleware.php
示例10: callback
public function callback(SocialAccountService $service, $provider)
{
$driver = Socialite::driver($provider);
$user = $service->createOrGetUser($driver, $provider);
Auth::login($user, true);
return redirect()->intended('/');
}
开发者ID:avil13,项目名称:lab.friends,代码行数:7,代码来源:SocialController.php
示例11: dashboard
public function dashboard()
{
$messages = Redis::lrange('messages', 0, -1);
$messages = $messages ? $messages : [];
$tasks = Auth::user()->tasks()->get();
return view('dashboard', compact('messages', 'tasks'));
}
开发者ID:ColDog,项目名称:laravel-first,代码行数:7,代码来源:PagesController.php
示例12: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
if (Auth::check()) {
return Redirect::to('/profile');
}
return View::make('user-package::registration.create');
}
开发者ID:raymondidema,项目名称:user-package,代码行数:12,代码来源:RegistrationController.php
示例13: edit
public function edit(Donations $donations)
{
if (!Auth::check()) {
return redirect('donations');
}
return view('edit', compact('donations'));
}
开发者ID:Tropuska,项目名称:DWA-seminar2,代码行数:7,代码来源:DonationsController.php
示例14: 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::user()->id == 1) {
return $next($request);
}
return redirect()->guest('login')->withErrors(trans('auth.admin'));
}
开发者ID:timpressive,项目名称:art-auction,代码行数:15,代码来源:Administrator.php
示例15: postLogin
/**
* Process a login HTTP POST
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin(Request $request)
{
//TODO
// dd($request->all());
//\Debugbar::info("Entra postlogin");
//echo "prova";
$this->validate($request, ['email' => 'required|email', 'password' => 'required']);
// if($this->login($request->email, $request->password)){
// //REDIRECT TO HOME
// //Session::set('authenticated',true);
//
// return redirect()->route('auth.home');
// }else{
// $request->session()->flash('login_error', 'Login Incorrecte');
// return redirect()->route('auth.login');
// //REDIRECT BACK
// }
if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
// Authentication passed...
return redirect()->route('auth.home');
//return redirect()->intended('auth.home');
} else {
return redirect()->route('auth.login');
}
}
开发者ID:OscarDuranX,项目名称:Auth,代码行数:30,代码来源:LoginController.php
示例16: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::user()) {
Cache::forever('last_seen_' . Auth::user()->id, date('Y-m-d H:i:s'));
}
return $next($request);
}
开发者ID:Denniskevin,项目名称:Laravel5Starter,代码行数:14,代码来源:LastActivity.php
示例17: postLogin
public function postLogin(\Illuminate\Http\Request $request)
{
$username = $request->input('username');
$password = $request->input('password');
// First try to log in as a local user.
if (Auth::attempt(array('username' => $username, 'password' => $password))) {
$this->alert('success', 'You are now logged in.', true);
return redirect('users/' . Auth::user()->id);
}
// Then try with ADLDAP.
$ldapConfig = \Config::get('adldap');
if (array_get($ldapConfig, 'domain_controllers', false)) {
$adldap = new \adldap\adLDAP($ldapConfig);
if ($adldap->authenticate($username, $password)) {
// Check that they exist.
$user = \Ormic\Model\User::where('username', '=', $username)->first();
if (!$user) {
$user = new \Ormic\Model\User();
$user->username = $username;
$user->save();
}
\Auth::login($user);
//$this->alert('success', 'You are now logged in.', TRUE);
return redirect('');
//->with(['You are now logged in.']);
}
}
// If we're still here, authentication has failed.
return redirect()->back()->withInput($request->only('username'))->withErrors(['Authentication failed.']);
}
开发者ID:samwilson,项目名称:ormic,代码行数:30,代码来源:UsersController.php
示例18: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$template = new Template($request->all());
$template->user_id = Auth::user()->id;
$template->save();
return Redirect::route('templates.index');
}
开发者ID:slipperydippery,项目名称:question,代码行数:13,代码来源:TemplatesController.php
示例19: newComment
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function newComment(CommentFormRequest $request)
{
$user_id = Auth::user()->id;
$comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content'), 'user_id' => $user_id));
$comment->save();
return redirect()->back()->with('custom_success', 'Your comment has been created!');
}
开发者ID:ErtyGi,项目名称:wsapp,代码行数:12,代码来源:CommentsController.php
示例20: it_logs_a_user_out
/**
* @test
*/
public function it_logs_a_user_out()
{
$this->preparePageContent();
$user = factory('App\\User')->create();
$this->actingAs($user)->visit('admin/logout');
$this->assertFalse(Auth::check(), 'user not logged out');
}
开发者ID:michaeljoyner,项目名称:expeditionists,代码行数:10,代码来源:AuthTest.php
注:本文中的Illuminate\Support\Facades\Auth类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论