gutter/hybridauth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gutter/hybridauth

Composer 安装命令:

composer require gutter/hybridauth

包简介

hybridauth/hybridauth integration for Nette Framework

README 文档

README

This is hybridauth/hybridauth integration for Nette Framework.

Installation

The best way to install Gutter\HybridAuth is via Composer:

$ composer require gutter/hybridauth

Usage

You can use the HybridAuth as an extension.

Configuration

First you have to set the extension up in config.neon.

extensions:
    hybridAuth: Gutter\HybridAuth\DI\HybridAuthExtension

hybridAuth:
    base_url: https://myapp.com/auth/process
    providers:
        Google:
            enabled: true
            keys:
                id: [your-google-key]
                secret: [your-google-secret]
        Facebook:
            enabled: true
            keys:
                id: [your-facebook-key]
                secret: [your-facebook-secret]
            scope: email

Implementation

Then the implementation of /auth controller could look like this:

class AuthPresenter extends BasePresenter
{
    /** @var \Gutter\HybridAuth\Manager @inject */
    public $hybridAuth;

    /** @var AuthModel @inject */
    public $model;

    public function actionProcess()
    {
        $this->hybridAuth->process();
    }

    public function actionGoogle()
    {
        $adapter = $this->hybridAuth->authenticate('Google');
        $userProfile = $adapter->getUserProfile();

        $user = $this->model->getUserByEmail($userProfile->email);
        if ($user) {
            $this->login($user);
        }

        $this->redirect('Login:failed');
    }

    public function actionFacebook()
    {
        $adapter = $this->hybridAuth->authenticate('Facebook');
        $userProfile = $adapter->getUserProfile();

        $user = $this->model->getUserByEmail($userProfile->email);
        if ($user) {
            $this->login($user);
        }

        $this->redirect('Login:failed');
    }
}

统计信息

  • 总下载量: 2.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-04-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固