本文整理汇总了PHP中Illuminate\Support\Facades\Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Auth类的具体用法?PHP Auth怎么用?PHP Auth使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Auth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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]));
}
}
示例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.');
}
示例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');
}
示例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;
}
示例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");
}
示例7: validate
/**
* @param $credentials
* @throws ValidationFailed
*/
public function validate($credentials)
{
$valid = Auth::validate($credentials);
if (!$valid) {
throw new ValidationFailed();
}
}
示例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']);
});
}
示例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);
}
示例10: callback
public function callback(SocialAccountService $service, $provider)
{
$driver = Socialite::driver($provider);
$user = $service->createOrGetUser($driver, $provider);
Auth::login($user, true);
return redirect()->intended('/');
}
示例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'));
}
示例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');
}
示例13: edit
public function edit(Donations $donations)
{
if (!Auth::check()) {
return redirect('donations');
}
return view('edit', compact('donations'));
}
示例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'));
}
示例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');
}
}