Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Add alias for the Guard contract to auth.driver #2

Merged
merged 1 commit into from
Mar 19, 2015

Conversation

wpillar
Copy link
Contributor

@wpillar wpillar commented Mar 16, 2015

@euantorano @JN-Jones when I created a new controller, I got a "Mybb\Auth\Contracts\Guard is not instantiable" exception from the container when it was trying to resolve MyBB\Core\Http\Controllers\Controller, this fixed it.

Did either of you have a similar problem at any stage? I can't really see how it ever would have worked?

@JN-Jones
Copy link
Contributor

The current controllers use Laravel/Auth/Guard which is resolved to our own auth implementation.

@euantorano
Copy link
Member

Odd. It's injected elsewhere, but it looks like most are just injecting Illuminate\Auth\Guard, which happens to work due to other DI registrations.

The method for extending Guard is a particularly painful one unfortunately, and is probably one of the most difficult parts of Laravel to extend.

@wpillar
Copy link
Contributor Author

wpillar commented Mar 16, 2015

@JN-Jones Where is this contract bound into the container? https://github.com/mybb/mybb2/blob/master/app/Http/Controllers/Controller.php#L7

I couldn't find anywhere that it bound that contract to a concretion.

@JN-Jones
Copy link
Contributor

It doesn't use the contract somewhere else. It uses laravels guard implementation instead. Which resolves to ours as laravels isn't initialed at all.

@euantorano
Copy link
Member

If this fixes the issue though, we should merge it.

That contract is bound through other contracts (the Guard instance is created by the manager). It's a bit of a convoluted process, with manual instantiation in the Manager. This is how Laravel's core does it too.

@wpillar
Copy link
Contributor Author

wpillar commented Mar 16, 2015

So we should be type-hinting for Illuminate\Auth\Guard everywhere rather than MyBB\Auth\Contracts\Guard?

@JN-Jones
Copy link
Contributor

Yep. Also we should suggest to laravel to make extending easier. Extending three classes just to change the hashing algorithm is pretty stupid.

@JN-Jones
Copy link
Contributor

If this commit fixes that and allows using the contract it should be changed

@euantorano
Copy link
Member

IMO we should type hint MyBB\Auth\Contratcs\Guard as then it's clear which contract we're using. The current approach hides this and may lead to confusion further down the line.

@wpillar
Copy link
Contributor Author

wpillar commented Mar 16, 2015

Agree with @euantorano.

The hashing algorithm we're using instead is still bcrypt right? Or rather, something much much better than md5 or sha* ?

@euantorano
Copy link
Member

Yes, we use BCrypt by default.

The alternative hashing algorithms are meant to enable support for the future merge system as other boards use other hashing mechanisms. This package allows those mechanisms to still function after a merge without forcing password resets for all users.

@JN-Jones
Copy link
Contributor

By default we're using bcrypt (laravels default class). However we also support different ones like mybb 1.x, phpbb, phpass etc. Everything the merge system may need

@euantorano
Copy link
Member

EG: Support for old MyBB 1.x passwords so that upgraded boards don't require 100% password resets for all users.

@wpillar
Copy link
Contributor Author

wpillar commented Mar 16, 2015

I see. Good chat.

If we could merge this that would be great 👍

We should also try and enforce hinting on our own contract rather than the Illuminate one.

@JN-Jones
Copy link
Contributor

Yep, should be changed everywhere (only online from mobile so can't merge/test anything)

@wpillar
Copy link
Contributor Author

wpillar commented Mar 18, 2015

Can we merge this @euantorano @JN-Jones ?

@JN-Jones
Copy link
Contributor

Nothing against it - can you also change the controllers then?

@wpillar
Copy link
Contributor Author

wpillar commented Mar 18, 2015

Sure, I'll do it once this is merged 👍

JN-Jones added a commit that referenced this pull request Mar 19, 2015
Add alias for the Guard contract to auth.driver
@JN-Jones JN-Jones merged commit 19fc07b into master Mar 19, 2015
@JN-Jones JN-Jones deleted the fix-guard-not-instantiable branch March 19, 2015 17:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants