Coder Social home page Coder Social logo

kchapple / wordpress-auth-driver-laravel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ahsankhatri/wordpress-auth-driver-laravel

0.0 2.0 0.0 11 KB

A package to provide wordpress users in laravel authentication system.

License: MIT License

PHP 100.00%

wordpress-auth-driver-laravel's Introduction

Wordpress Auth Driver for Laravel

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Intelligence Status License

Installation

To install this package you will need

  • Laravel 5.4
  • PHP 5.5

The best way to install this package is with the help of composer. Run

composer require ahsankhatri/wordpress-auth-provider

or install it by adding it to composer.json then run composer update

"require": {
    "ahsankhatri/wordpress-auth-provider": "^1.0",
}

Setup

Once you have installed this package from the composer, make sure to follow the below steps to configure.

config/app.php
'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    ...,

    MrShan0\WordpressAuth\WordpressAuthServiceProvider::class,
]

Also, to register authentication guard.

config/auth.php
'guards' => [
    ...,
    'wordpress' => [
        'driver' => 'session',
        'provider' => 'wordpress',
    ],
'providers' => [
    ...,
    'wordpress' => [
        'driver' => 'eloquent.wordpress',
        'model' => MrShan0\WordpressAuth\Models\WordpressUser::class,
    ],
'passwords' => [
    ...,
    'wordpress' => [
        'provider' => 'wordpress',
        'table' => 'password_resets',
        'expire' => 60,
    ],

Configuration

password_resets table (from Laravel default auth mechanism) is required to hold reset password token. If you do not have password_resets table then use this migration instead

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePasswordResetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('password_resets');
    }
}

Usage

You need to define wordpress guard explicitly to load the driver.

Examples

Auth::guard('wordpress')->loginUsingId(5);

// or login using email and password
Auth::guard('wordpress')->attempt([
    'user_email' => '[email protected]',
    'user_pass' => 'quickbrownfox'
]);

// get user object
Auth::guard('wordpress')->user();

// logout
Auth::guard('wordpress')->logout();

You may also change default guard in config/auth.php then your code will look like

Auth::loginUsingId(5);

Changelog

CHANGELOG

Credits

Thanks to the community of Laravel.

Copyright and License

Copyright (c) 2016 Ahsaan Muhammad Yousuf, MIT License

wordpress-auth-driver-laravel's People

Contributors

ahsankhatri avatar kchapple avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.