Git Product home page Git Product logo

multi-auth's People

Contributors

codepotato avatar ebbbang avatar hesto avatar joseluisq avatar mikerodham avatar samshameem avatar zeroc0d3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multi-auth's Issues

Logout does not logout

I have added this in. Changed the login page to reflect my own layout as well as the register page.

I can register and login fine but when I click logout its not logging me out. It takes me back to the root but if I visit the login page again then I see that I am actually logged in.

Is there something I need to add to log out a user?

[Illuminate\Contracts\Filesystem\FileNotFoundException]

i follow the tutorial till the end but when i want to type "php artisan multi-auth:install admin -f"
i keep getting these error.

[Illuminate\Contracts\Filesystem\FileNotFoundException]
File does not exist at path C:{MY_LARAVEL_DIRECTORY}/routes/web.php

i currently use laravel 5.3
thank you

Grouping routes prefix

Hi Hesto,

I got an idea to create grouping routes prefix in multi-auth/src/stubs/routes/web.stub

//{{singularClass}} Group Routes
Route::group(['prefix' => '{{singularSlug}}'], function () {
  //routes: [project]/{{singularSlug}}

  //{{singularClass}} Login
  Route::get('', '{{singularClass}}Auth\LoginController@showLoginForm');
  Route::get('/login', '{{singularClass}}Auth\LoginController@showLoginForm');
  Route::post('/login', '{{singularClass}}Auth\LoginController@login');
  Route::post('/logout', '{{singularClass}}Auth\LoginController@logout');

  //{{singularClass}} Register
  Route::get('/register', '{{singularClass}}Auth\RegisterController@showRegistrationForm');
  Route::post('/register', '{{singularClass}}Auth\RegisterController@register');

  //{{singularClass}} Passwords
  Route::post('/password/email', '{{singularClass}}Auth\ForgotPasswordController@sendResetLinkEmail');
  Route::post('/password/reset', '{{singularClass}}Auth\ResetPasswordController@reset');
  Route::get('/password/reset', '{{singularClass}}Auth\ForgotPasswordController@showLinkRequestForm');
  Route::get('/password/reset/{token}', '{{singularClass}}Auth\ResetPasswordController@showResetForm');
});

$redirectTo with param

I want to set my redirect after logging in and logging out to route with dynamic param. Something like

public $redirectTo = '/cms-name/en/home';

This one above works fine but I need that "en" to be dynamic. How can I achieve that?
Thanks a lot!

Auth Route

Hello @Hesto i installed your package into a new project all's fine, good job. i'm new and just started job with L5.3
that looks like a support request:
i want to now with multi-auth how use roles and permissions in the right way (AUTHENTICATION access)? For example i want that a someone who is registered can't have access level to the admin dashboard... as much as i marked him as admin.

admin is considered logged in even if he closed the browser and re open it!

I used hesto package last night and when I login with laravel make:auth package as user ,after closing the browser I am logged out.
when I logged in as admin, even when I closed the browser admin is logged in yet!!
how can I set time out for admin to be logged in? and at least how to consider admin logout when he closed browser?
than you for the package.

routing issue

I found a routing issue.
e.g. http://domain.app:8016/admin/home (not login yet) -> http://domain.app:8016/login
The correct redirecting url is /admin/login , not /login.

I modify the following code. It can redirect correct url and fix auth.blade.php.

app/Providers/RouteServiceProvider.php

    protected function mapAdminRoutes()
    {
        Route::group([
-            'middleware' => ['web', 'admin', 'auth:admin'],
+            'middleware' => ['web', 'admin'],
            'prefix' => 'admin',
            'as' => 'admin.',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/admin.php');
        });
    }

resources/views/admin/layout/auth.blade.php

                 <!-- Right Side Of Navbar -->
                 <ul class="nav navbar-nav navbar-right">
                     <!-- Authentication Links -->
-                    @if (Auth::guest())
+                    @if (Auth::guard('admin')->guest())
                         <li><a href="{{ url('/admin/login') }}">Login</a></li>
                         <li><a href="{{ url('/admin/register') }}">Register</a></li>
                     @else
                         <li class="dropdown">
                             <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
-                                {{ Auth::user()->name }} <span class="caret"></span>
+                                {{ Auth::guard('admin')->user()->name }} <span class="caret"></span>
                             </a>

I hope this is useful.

Named Routes in Multi Auth Route files

whenever i create a new route in a guard route, when i call the route name from my controller, it throws errror saying the route name is undefined
Route [nameOfRoute] not defined.
Please assist me to solve this issue

Getting logged in user

How do i get the logged in user in the multi auth i just created like i'll check the number user with (Auth::check())

errors for different login forms

how to display specific form errors using message bag for multi auth .I have modals and the error are been displayed in all modal forms.
Where can i add witherrors method.

auth get data

Auth::user()->id error

auth me "admin" and "superadmin" 2auth check get id Admin::admin()->id ???

Issue when using with Socialite

I am trying to use Socialite (facebook login in particular). Based on the setup instructions and any tutorials I have found, I get the following error:

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of Laravel\Socialite\Two\User given, called in xxxxx/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php on line 294 and defined

Is it possible, the two can work togeather?

Check logged user in view

How do I check if the user is logged in inside my view that is being used on "/" route? I can only do it on /{guard}/home

User Actions

Hello @Hesto In addition to set Multi-auth, how to provide a way to authorize user (Admin or Employee) actions against a given resource?
Laravel's default Authorization approach does it in a simple way.

Tokenmismatch exception on existing project

i tried to implement multiple authentication on my laravel 5.3 project. i used sub-domain routing for each authentication but when i tried to login it gives tokenmismatch exception . i added csrf field and still not woking
i created a fresh laravel 5.3 install and it worked. what i m missing

Laravel 5.3 production usage

I have a question and it's, why do you say that only use these package for local development and not production? and what should I do if I want to use it for production? what would happen if I do? does it make my application less secure?

Method mapAdminRoutes does not exist.

[BadMethodCallException] Method mapAdminRoutes does not exist. when i ran php artisan migrate

i think you miss mapAdminRoutes in RouteServiceProvider

protected function mapAdminRoutes()
    {
        Route::group([
            'middleware' => ['admin', 'web'],
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/admin.php');
        });
    }

Use separate password_resets_table for each

This package uses same database table (password_resets) for each guard.

But there is problem using this -
Lets take an example :
There are two types of users

  • Admin
  • Customer

An admin can be a customer and a customer can be an admin. Same person have two different account but with same email address.
Now when that admin user make any password reset request, application will overwrite any existing (this can be himself as customer) request for same email address. This way the tokens gets lost and email link becomes invalid.

The possible solution is to use a separate table for each user type -

  • Create a new admin_password_resets table
<?php

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

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

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('admin_password_resets');
    }
}
  • Specify this table name in app/config/auth.php file
'passwords' => [
        'admins' => [
            'provider' => 'admins',
            'table' => 'admin_password_resets',
            'expire' => 60,
        ],

        'users' => [
            'provider' => 'users',
            'table' => 'password_resets',
            'expire' => 60,
        ],
    ],
  • That's it, Laravel will use this new table for admins password reset tokens from now

Redirect when access admin/* if not login

Hi
Route::group([ 'middleware' => ['web', 'admin', 'auth:admin'], 'prefix' => 'admin', 'as' => 'admin.', 'namespace' => $this->namespace, ], function ($router) { require base_path('routes/admin.php'); });
redirect /login when access admin/home if not login
if I remove 'auth:admin', it redirect /admin/login that I want but
`$users[] = Auth::user();
$users[] = Auth::guard()->user();
return null
why that?? and how to fix it.
Thanks

Logout problem

Hi.
Logout method doesn't work in laravel 5.3. I solved it by changing post method to get method in routes.
Also, I had a problem when I removed public folder from my project. Multi-auth routes don't work.

/admin/logout set as post route

The /{guard}/logout is set to a post request and therefore a get request will not work. I've added a get request to the routes:
Route::get('admin/logout', 'AdminAuth\LoginController@logout');

Could it be a good idea to add this as an additional default route when a new guard is created?

Redirect Problem

these are my current routes
/admin/login
/admin/home

After logging in as admin when i enter /admin/login it is still showing the login page. same with the register route. its not redirecting back to home.

The screen shots are examples event i logged in as admin.
Please check them.
login1
login2
login3

different admin route

Is there any quick way to set different admin route but keeping admin guard?

php artisan multi-auth:install admin -f

but instead of my-website.com/admin/login I want to use my-website.com/cms-name/login

Does not record {guard}

I did a clean installation of Laravel 5.3 and followed the steps but when testing the registry this redirect to the same page without showing or errors.

The same happens when you do not put content.

Namespace issues in Laravel 5.3

@Hesto Thank you for a useful package!
Correct me if I am wrong, but the stubs need to have {{namespace}} instead of the default App\ being hard-coded? Just realized this after having to refactor things, since the package wasn't working for me.

Also, noticed that the --domain flag in the artisan command is missing or deprecated.
Thanks again, and keep up the good work!

Passport Multi-Auth

Looks like this package doesn't support multi-auth using Passport. I'm using Passport for the User API authentication but I'm unable to use it for Admin API authentication at the same time created using this package.

redirect back to intended page issue

I am having a UserAuth controller,
and i have added the Middleware to the route

Route::get('/', function () {
    return view('welcome');
})->middleware('user');

but when i try this after loggin in it should come back to home page instead of user/home,
how to change this i have changed this line in middleware RedirectIfUser

public function handle($request, Closure $next, $guard = 'user')
	{
	    if (Auth::guard($guard)->check()) {
	        //return redirect('user/home');
	        return redirect()->intended('user/home');
	    }
	    return $next($request);
	}

but no effect

the only where it's working is by changing in UserAuth/LoginController

public $redirectTo = '/user/home';

to public $redirectTo = '/';

but i dont want as i may have to add this middleware to multiple routes and after logging in it should remain on the protected routes and not go to the user/home..

Method mapEmployerRoutes does not exist

Followed setup instructions using php artisan multi-auth:install employeer -f (yes, I realize I spelled "employer" wrong, too tired). After everything is created, the following error appears:

[BadMethodCallException]                 
Method mapEmployeerRoutes does not exist.

RouteServiceProvider.php has this added, but the method is not in the class:

public function map()
    {
        $this->mapApiRoutes();

        $this->mapWebRoutes();

        $this->mapEmployeerRoutes(); // method not found

        //
    }

I created the missing method as so:

protected function mapEmployeerRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/employeer.php');
        });
    }

This allows me to access /employeer/login, etc., and everything there works. But the employeer/home route returns a 404 error and is not listed when running php artisan route:list. What am I missing??

Laravel 5.3

After changing DB name (connection) it takes default db name and throw error

I have two db for example
DB1 is default for all user
DB2 for admin so i made two different connection first one MySql and second one is MySql2
when i changed admin model connection i takes default connection and throw an error that table not exist,
here is my connection code in model i am using laravel 5.3
protected $connection = 'mysql2';
so i am wrong or there is bug

Not staying logged in

Hi, in my template.blade.php I have the following code in the top of the page:

@if (Auth::guard("doctor")->user())
    Welcome, {{ Auth::guard("doctor")->user()->name }}
    <a href="{{ url('/doctor/logout') }}">Logout</a>
@endif

Right after registering or logging in, it show the welcome message, but when the user go to any other page the session is lost... I'm using the default login system provided by multi-auth... Any way to keep it logged in?

Extension documentation

Hi, Could You add to note information about what is need n=in model in case of using --model option.
I had model previously generated with artisan.

Wrong redirect when user is not logged in.

Hello,

I tried to use this package, but i run into a problem. After this:

php artisan multi-auth:install admin -f

Evertything looks fine, but when i try to reach /admin/home without active session, i got redirected to /login, instead of /admin/login.

Data not written

Hi, I have followed all instructions and able to access the views, however when submitting registration (validation works fine) I am redirected back to the registration page and data not written to the relevant table (so table in my case vendors table is empty). No errors are thrown.

Anything I can try to debug?

Lucid ?

Have no idea about what lucid option is. Could some one explain or give me some ref links to learn more about it ? ๐Ÿ˜„

Authenticated User

Hey Piotr,

Thanks for the plugin - saved me so much time!.

So I see:

$users[] = Auth::user();
$users[] = Auth::guard()->user();
$users[] = Auth::guard('admin')->user();

On routes/admin.php all give a "Admin" object, even though default guard is "web", which should give "User" object.

When I specify the guard as "web" it shows a "User" object.

Is that a bug, or something one should watch out for?

Thanks in Advance.

Remove register from multi auth

Hi i have a question,

How do you remove the register from auth, because i don't want someone register from the site.
This is for admin, so another admin being created by super admin.

Thanks.

Changing the parameters in authentication

Need a little help to change the parameters in authentication.
Example :-
By default package gives an authentication with email and password. Instead i wan't to use a local Identity no and password.

How to automatic routing "/admin" ?

The package is great! I Love it.

my route in admin.php like this

Route::resource('amenities', 'AmenityController');

when I try in view: {!! route('amenities.show', [$amenity->id]) !!} its error

ErrorException in UrlGenerator.php line 314: Route [amenities.show] not defined.

So I must add admin to {!! route('admin.amenities.show', [$amenity->id]) !!} then it works.

Is there any solutions without add admin keyword to route?

another solution is, create the route in web.php & add middleware.
the code like this

Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function () {
    Route::resource('amenities', 'AmenitiesController');
});

Missing method when creating guard

After install multi-auth in project (step 3) error appears Method mapEmployeeRoutes does not exist.. Install should add also method to RouteServiceProvider.php named mapGuardRoutes()

Laravel 5.3 logout problem with default login

Hello,
I think this package is great but I have one problem. I create admin guard and everything work.
After that I run make:auth to use default LoginController for my users but when I login as users and logout after that it logout the admin user as well?
Is that normal behave? Can I separate their sessions so when logout user the admin stays logged in?
Thanks

Could not scan for classes inside...

for help! I'm newer in laravel.
and when i install multi-auth,it says:

reasonpun@vultr:/ebook$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files


  [RuntimeException]
  Could not scan for classes inside "/ebook/vendor/hesto/multi-auth/src/commands" which does not appear to be a file nor a folder


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

thank you for helping me~

Logout issue

The scaffolding generated for the {guard} has get request for logout which is actually supposed to be a post request.

Route::get('admin/logout', 'AdminAuth\LoginController@logout');

replace with

Route::post('admin/logout', 'AdminAuth\LoginController@logout');

Redirection problem

Hi, i am having 2 issues with the multi-auth.
I have a user and admin login (2 separate login pages).

  1. When i am not logged as an admin and i want to access a page (example : admin/test123)
    It redirect me to the user login and i am not sure where to look to correct that. I don't want my admins to fall into the user platform.

  2. When i login as an admin, it sometimes redirect me to the user login too. The login is working fine because if i manually do /admin, i can see the admin index. It only happen the first time i try like something was saved into a cache. I don't know.

Thanks!

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.