All Projects β†’ laravie β†’ Authen

laravie / Authen

Licence: mit
🚦 User Authentication Identifiers for Laravel

Projects that are alternatives of or similar to Authen

Laravel Scaffold
The base for developing awesome projects
Stars: ✭ 142 (+167.92%)
Mutual labels:  laravel, authentication
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+333.96%)
Mutual labels:  laravel, authentication
Fortify Ui
Laravel Fortify driven replacement to the Laravel UI package
Stars: ✭ 192 (+262.26%)
Mutual labels:  laravel, authentication
Jwt Auth
πŸ” JSON Web Token Authentication for Laravel & Lumen
Stars: ✭ 10,305 (+19343.4%)
Mutual labels:  laravel, authentication
Laravel5.7 Vue Cli3 Boilerplate
Boilerplate / Starter kit. Laravel 5.7, Vue CLI 3 β€” Authentication with Email Verification. REST API.
Stars: ✭ 52 (-1.89%)
Mutual labels:  laravel, authentication
Laravel Auth
A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
Stars: ✭ 128 (+141.51%)
Mutual labels:  laravel, authentication
Laravel Auth
Laravel 8 with user authentication, registration with email confirmation, social media authentication, password recovery, and captcha protection. Uses offical [Bootstrap 4](http://getbootstrap.com). This also makes full use of Controllers for the routes, templates for the views, and makes use of middleware for routing. The project can be stood u…
Stars: ✭ 2,692 (+4979.25%)
Mutual labels:  laravel, authentication
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (+49.06%)
Mutual labels:  laravel, authentication
Laravel Acl
This package helps you to associate users with permissions and permission groups with laravel framework
Stars: ✭ 404 (+662.26%)
Mutual labels:  laravel, authentication
Permissionmanager
Admin interface for managing users, roles, permissions, using Backpack CRUD
Stars: ✭ 363 (+584.91%)
Mutual labels:  laravel, authentication
Laravel Passport Android
Laravel + Passport for an Android App
Stars: ✭ 116 (+118.87%)
Mutual labels:  laravel, authentication
Google2fa Laravel
A One Time Password Authentication package, compatible with Google Authenticator for Laravel
Stars: ✭ 618 (+1066.04%)
Mutual labels:  laravel, authentication
Sentinel
A framework agnostic authentication & authorization system.
Stars: ✭ 1,354 (+2454.72%)
Mutual labels:  laravel, authentication
Multi Auth
Laravel Multi-Authentication Package
Stars: ✭ 131 (+147.17%)
Mutual labels:  laravel, authentication
Laravel Single Session
This package prevents a User from being logged in more than once. It destroys the previous session when a User logs in and thereby allowing only one session per user.
Stars: ✭ 95 (+79.25%)
Mutual labels:  laravel, authentication
Laravel Adminless Ldap Auth
Authenticate users in Laravel against an adminless LDAP server
Stars: ✭ 199 (+275.47%)
Mutual labels:  laravel, authentication
Shinobi
πŸ‘Ί Simple and light-weight role-based permissions system for Laravel's built in Auth system.
Stars: ✭ 349 (+558.49%)
Mutual labels:  laravel, authentication
Sudo Su
Laravel package to easily login as other users during development.
Stars: ✭ 554 (+945.28%)
Mutual labels:  laravel, authentication
Eloquent Ldap
A Laravel 5.1 package that first tries to log the user against the internal database if that fails, it tries against the configured LDAP/AD server.
Stars: ✭ 19 (-64.15%)
Mutual labels:  laravel, authentication
Fake Auth
A fake auth service for prototyping authentication flows
Stars: ✭ 50 (-5.66%)
Mutual labels:  authentication

User Authentication Identifiers for Laravel

tests Latest Stable Version Total Downloads Latest Unstable Version License Coverage Status

Imagine you need to login a user with either "email", "username" or "phone number" just like how Facebook allows it. This is not possible with Laravel since you're limited to only one unique username/identifier key. This package attempt to solve the issue by allowing to use a unified key "identifier" and you can customize which attributes Laravel should check during authentication.

Installation

To install through composer, run the following command from terminal:

composer require "laravie/authen"

Usages

Service Provider

First you can attach the auth provider on App\Providers\AuthServiceProvider:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Laravie\Authen\BootAuthenProvider;

class AuthServiceProvider extends ServiceProvider
{
    use BootAuthenProvider;

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        $this->bootAuthenProvider();
    }
}

User Model

Secondly, you need to update the related App\User (or the eloquent model mapped for auth).

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravie\Authen\AuthenUser;

class User extends Authenticatable
{
    use Notifiable, AuthenUser;

    /**
     * Get the name of the unique identifier for the user.
     *
     * @return array
     */
    public function getAuthIdentifiersName()
    {
        return ['email', 'username', 'phone_number'];
    }
}

With this setup, you can now check either email, username or phone_number during authentication.

Configuration

Lastly, you need to update the config config/auth.php:

<?php

return [

    // ...

    'providers' => [
        'users' => [
            'driver' => 'authen',
            'model'  => App\User::class,
        ],
    ],

    // ...
];

Examples

Here's an example how to login.

<?php 

use Illuminate\Support\Facades\Auth;
use Laravie\Authen\Authen;

$data = [Authen::getIdentifierName() => '[email protected]', 'password' => 'foobar'];

if (Auth::attempt($data)) {
    // you can logged in, you can also pass your phone number of username to `identifier`.
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].