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


PHP auth函数代码示例

本文整理汇总了PHP中auth函数的典型用法代码示例。如果您正苦于以下问题:PHP auth函数的具体用法?PHP auth怎么用?PHP auth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: authenticated

 /**
  * Overrides the action when a user is authenticated.
  * If the user authenticated but does not exist in the user table we create them.
  * @param Request $request
  * @param Authenticatable $user
  * @return \Illuminate\Http\RedirectResponse
  * @throws AuthException
  */
 protected function authenticated(Request $request, Authenticatable $user)
 {
     // Explicitly log them out for now if they do no exist.
     if (!$user->exists) {
         auth()->logout($user);
     }
     if (!$user->exists && $user->email === null && !$request->has('email')) {
         $request->flash();
         session()->flash('request-email', true);
         return redirect('/login');
     }
     if (!$user->exists && $user->email === null && $request->has('email')) {
         $user->email = $request->get('email');
     }
     if (!$user->exists) {
         // Check for users with same email already
         $alreadyUser = $user->newQuery()->where('email', '=', $user->email)->count() > 0;
         if ($alreadyUser) {
             throw new AuthException('A user with the email ' . $user->email . ' already exists but with different credentials.');
         }
         $user->save();
         $this->userRepo->attachDefaultRole($user);
         auth()->login($user);
     }
     $path = session()->pull('url.intended', '/');
     $path = baseUrl($path, true);
     return redirect($path);
 }
开发者ID:ssddanbrown,项目名称:bookstack,代码行数:36,代码来源:LoginController.php

示例2: confirmEmail

 /**
  * @param $token
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function confirmEmail($token)
 {
     $user = User::whereActivationToken($token)->firstOrFail();
     $user->confirmEmail();
     auth()->login($user);
     return redirect()->intended()->with('success', 'Email verified!');
 }
开发者ID:eveseat,项目名称:web,代码行数:12,代码来源:EmailController.php

示例3: destroy

 /**
  * Removes the specified user from the specified role.
  *
  * @param int|string $roleId
  * @param int|string $userId
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($roleId, $userId)
 {
     $this->authorize('admin.roles.users.destroy');
     $role = $this->role->findOrFail($roleId);
     $user = $role->users()->findOrFail($userId);
     // Retrieve the administrators name.
     $adminName = Role::getAdministratorName();
     // Retrieve all administrators.
     $administrators = $this->user->whereHas('roles', function ($query) use($adminName) {
         $query->whereName($adminName);
     })->get();
     $admin = Role::whereName($adminName)->first();
     // We need to verify that if the user is trying to remove all roles on themselves,
     // and they are the only administrator, that we throw an exception notifying them
     // that they can't do that. Though we want to allow the user to remove the
     // administrator role if more than one administrator exists.
     if ($user->hasRole($admin) && $user->id === auth()->user()->id && count($administrators) === 1) {
         flash()->setTimer(null)->error('Error!', "Unable to remove the administrator role from this user. You're the only administrator.");
         return redirect()->route('admin.roles.show', [$roleId]);
     }
     if ($role->users()->detach($user)) {
         flash()->success('Success!', 'Successfully removed user.');
         return redirect()->route('admin.roles.show', [$roleId]);
     }
     flash()->error('Error!', 'There was an issue removing this user. Please try again.');
     return redirect()->route('admin.roles.show', [$roleId]);
 }
开发者ID:stevebauman,项目名称:ithub,代码行数:35,代码来源:RoleUserController.php

示例4: __construct

 public function __construct($criteria)
 {
     $this->scope['businessesIds'] = auth()->user()->businesses->transform(function ($item) {
         return $item->id;
     });
     $this->criteria = $criteria;
 }
开发者ID:josevh,项目名称:timegrid,代码行数:7,代码来源:SearchEngine.php

示例5: postStart

 /**
  * Show course details
  *
  * @return Response
  */
 public function postStart(Course\Course $course)
 {
     $section = $course->sections()->first();
     auth()->user()->courses()->attach($course);
     auth()->user()->sections()->attach($section);
     return redirect()->route('front.section', [$course, $section, $section->slug()]);
 }
开发者ID:siegessa,项目名称:uzem,代码行数:12,代码来源:MyController.php

示例6: authenticatePusher

 /**
  * Generate Pusher authentication token for currently logged user.
  *
  * @param  Request $request
  * @param  PusherManager $pusher
  *
  * @return string
  */
 public function authenticatePusher(Request $request, PusherManager $pusher)
 {
     $channelName = 'private-u-' . auth()->id();
     $socketId = $request->input('socket_id');
     $pusher->connection();
     return $pusher->socket_auth($channelName, $socketId);
 }
开发者ID:rafamontufar,项目名称:Strimoid,代码行数:15,代码来源:AuthController.php

示例7: saveEntry

 public function saveEntry(Request $request)
 {
     $id = hashids_decode($request->get('content'));
     $entry = Entry::findOrFail($id);
     $entry->saves()->create(['user_id' => auth()->id()]);
     return Response::json(['status' => 'ok']);
 }
开发者ID:rafamontufar,项目名称:Strimoid,代码行数:7,代码来源:SaveController.php

示例8: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     if (auth()->guest()) {
         return false;
     }
     return true;
 }
开发者ID:jay4497,项目名称:j4cms,代码行数:12,代码来源:UserRequest.php

示例9: index

 public function index()
 {
     if (auth()->check()) {
         return view('dashboard.index')->withLeftNavigation('dashboard');
     }
     return view('auth.login');
 }
开发者ID:daison12006013,项目名称:phalconslayer-admin,代码行数:7,代码来源:DashboardController.php

示例10: 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()->role == 1) {
         return $next($request);
     }
     return redirect('/home');
 }
开发者ID:Korogba,项目名称:mathlibrary,代码行数:14,代码来源:ReDirectToAdmin.php

示例11: getFavoriteList

 public function getFavoriteList()
 {
     $authId = auth()->user()->id;
     $favoritecandidatelist = \App\FavoriteCandidate::where('user_id', $authId)->get();
     $favoritepartylist = \App\FavoriteParty::where('user_id', $authId)->get();
     return view('user.favorites', compact('favoritecandidatelist', 'favoritepartylist'));
 }
开发者ID:kode-addict,项目名称:final-repo,代码行数:7,代码来源:UserController.php

示例12: build_workspace_menu

function build_workspace_menu($menuarray = array())
{
    global $base, $baseURL;
    foreach ($menuarray as $plmenu) {
        if ($plmenu) {
            foreach ($plmenu as $menuitem) {
                // Use a default image if we cant find the one specified.
                if (!file_exists($base . $menuitem['image']) or !$menuitem['image']) {
                    $menuitem['image'] = '/images/silk/plugin.png';
                }
                if (!$menuitem['tooltip']) {
                    $menuitem['tooltip'] = $menuitem['menutitle'];
                }
                // Check the authorization and print the menuitem if the are authorized
                if (auth($menuitem['authname'], 3) || !$menuitem['authname']) {
                    $wsmenuhtml .= <<<EOL

<div class="row"
     onMouseOver="this.className='hovered';"
     onMouseOut="this.className='row';"
     onClick="ona_menu_closedown(); {$menuitem['commandjs']};"
     title="{$menuitem['tooltip']}"
 ><img style="vertical-align: middle;" src="{$baseURL}{$menuitem['image']}" border="0"
 />&nbsp;{$menuitem['menutitle']}</div>

EOL;
                }
            }
        }
    }
    return $wsmenuhtml;
}
开发者ID:edt82,项目名称:ona,代码行数:32,代码来源:functions_gui.inc.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = auth()->user();
     $thread = new Thread($request->all());
     $user->threads()->save($thread);
     return redirect(route('intern.discuss.threads.show', [$thread->forum->slug, $thread->slug]));
 }
开发者ID:LaravelHamburg,项目名称:laravel-hamburg.com,代码行数:13,代码来源:ThreadController.php

示例14: store

 public function store(Requests\StorePostRequest $request, $post_id = null)
 {
     $post = Posts::findOrNew($post_id);
     if (empty($post)) {
         redirect()->back()->withInput();
     }
     $seo_title = $request->get('seo_title', '') != '' ? $request->get('seo_title') : $request->get('title');
     if ($request->hasFile('img')) {
         $filename = $this->_uploadMiniature($request->file('img'));
         $post->img = $filename;
     }
     $post->user_id = auth()->user()->id;
     $post->category_id = $request->get('category_id');
     $post->title = $request->get('title');
     $post->excerpt = $request->get('excerpt');
     $post->content = $request->get('content');
     $post->seo_title = strip_tags($seo_title);
     $post->seo_description = strip_tags($request->get('seo_description'));
     $post->seo_keywords = mb_strtolower(strip_tags($request->get('seo_keywords')));
     $post->status = $request->get('status');
     $post->published_at = $request->get('published_at');
     if ($request->has('update_slug')) {
         $post->resluggify();
     }
     $post->save();
     $this->_setTags($request->get('tags'), $post->id);
     if ($request->has('ping')) {
         Pinger::pingAll($post->title, route('view', ['slug' => $post->slug]));
     }
     Notifications::add('Blog post saved', 'success');
     return Redirect::route('root-post-edit', ['post_id' => $post->id]);
 }
开发者ID:garf,项目名称:0ez,代码行数:32,代码来源:PostsController.php

示例15: save

 public static function save($data)
 {
     $code = (new Parcels())->getNextCode();
     $description = $data[0];
     event(new ActivityLog(auth()->user()->username . ' created a parcel ' . $description . ' with the code ' . $code . ' successfully via CSV Upload.'));
     return auth()->user()->parcels()->create(['weight' => 1, 'town_id' => 1, 'status_id' => 1, 'description' => $description, 'code' => $code, 'destination' => $data[1]]);
 }
开发者ID:richardkeep,项目名称:tracker,代码行数:7,代码来源:CSVUpload.php


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