Comments (34)
If you are only going to use email you need to specify email only. Example:
Confide::logAttempt( array('email' => $user['email'], 'password' => $user['password']), true, array('email') )
Side note: I did this as it would be done in php 5.3, your example in php 5.4 would look like:
Confide::logAttempt( ['email' => $user['email'], 'password' => $user['password']], true, array('email') )
from confide.
@andrew13 : I am passing an array as the first parameter, it is returning true for the logAttempt meaning the database call and check passed, unless without passing the $identity_columns would change the session behavior
from confide.
When did you last do a composer update? You should be required to pass in username and email unless you specify only email.
from confide.
@andrew13 : just now and also, according to master, it's optional: https://github.com/Zizaco/confide/blob/master/src/Zizaco/Confide/Confide.php#L95
The validation part works perfectly fine, is the fact that if you authenticate 2 users in a row , the Confide::user() doesn't get updated accordingly
from confide.
Not exactly, both username and email will be checked for in the $credentials array. Username is checked for first, followed by email.
if($i == 0)
{
$user_model = $user_model->where($column,'=',$credentials[$column]);
}
else
{
$user_model = $user_model->orWhere($column,'=',$credentials[$column]);
}
Which, in your example, the sql will result in
where username
= null
OR
where email
= $user['email']
Since the column username is not defined in the $credentials array, when the loop attempts to find it it will spit out a notice and return null. So you could ignore it but it isn't safe to do so.
from confide.
weird..how come it returns true for me, let me double check my code, will update this thread
from confide.
I haven't been able to confirm your bug, but let's keep working on it until we find the solution. Maybe there's a bug in there somewhere.
When you do
Confide::logAttempt(['email' => $user['email'], 'password' => $user['password']]);
Confide::user(); //What does this return?
Confide::logout();
Confide::logAttempt(['email' => $user['email'], 'password' => $user['password']]);
Confide::user(); //this returns null
What does it return?
from confide.
perhaps I need to note that I am doing this inside phpunit environment. I am not sure if that changes anything or not.
I am working on it, will update soon
from confide.
ok, I tried it and Confide::user() returns null
this is my logAttempt
if (Confide::logAttempt(['email' => $input['email'], 'password' => $input['password']], true, ['email'])){
from confide.
This does actually bring up a good point. We could have it so it checks the array index and if it exists do the where, if not don't. This would avoid the check against null. Added a pull request for this case.
from confide.
It still doesnt explain why Confide::user() returns null after 2 logAttempts though, I havent tried it in a browser environment, I am in phpunit
from confide.
No it doesn't, but just made me think of it. I'll be testing in 5.4 w/ database sessions momentarily. Waiting for my vm to update.
from confide.
ah, thanks for checking this up @andrew13
from confide.
ok, I tried it and Confide::user() returns null
this is my logAttempt
if (Confide::logAttempt(['email' => $input['email'], 'password' => $input['password']], true, ['email'])){
So it gives you null both times? or just the second?
from confide.
@hyusetiawan You're welcome
from confide.
@andrew13 : the second, the first time works just fine
from confide.
Great, I'll let you know what I find out.
from confide.
So I did this through a controller:
Confide::logAttempt( ['email'=>'[email protected]','password'=>'admin'], true, ['email'] );
var_dump(Confide::user());
Confide::logout();
Confide::logAttempt( ['email'=>'[email protected]','password'=>'admin'], true, ['email'] );
var_dump(Confide::user());
die();
Ended up with both logged in:
object(User)[392]
protected 'table' => string 'users' (length=5)
protected 'hidden' =>
array (size=1)
0 => string 'password' (length=8)
public 'autoHashPasswordAttributes' => boolean true
public 'validationErrors' =>
object(Illuminate\Support\MessageBag)[393]
protected 'messages' =>
array (size=0)
empty
protected 'format' => string '<span class="help-inline">:message</span>' (length=41)
public 'autoHydrateEntityFromInput' => boolean false
public 'forceEntityHydrationFromInput' => boolean false
public 'autoPurgeRedundantAttributes' => boolean false
protected 'purgeFilters' =>
array (size=0)
empty
protected 'purgeFiltersInitialized' => boolean false
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
public 'timestamps' => boolean true
protected 'attributes' =>
array (size=8)
'id' => string '1' (length=1)
'username' => string 'admin' (length=5)
'email' => string '[email protected]' (length=14)
'password' => string '$2y$08$wcSSvuDQsLF7p6WyHkPSF.QRbaqkE/a9Ro4f/taWP6Cu8GIYran8y' (length=60)
'confirmation_code' => string 'fae75df69e37b9d66cb955004fe3c4a7' (length=32)
'confirmed' => string '1' (length=1)
'created_at' => string '2013-03-18 00:59:08' (length=19)
'updated_at' => string '2013-03-18 00:59:08' (length=19)
protected 'original' =>
array (size=8)
'id' => string '1' (length=1)
'username' => string 'admin' (length=5)
'email' => string '[email protected]' (length=14)
'password' => string '$2y$08$wcSSvuDQsLF7p6WyHkPSF.QRbaqkE/a9Ro4f/taWP6Cu8GIYran8y' (length=60)
'confirmation_code' => string 'fae75df69e37b9d66cb955004fe3c4a7' (length=32)
'confirmed' => string '1' (length=1)
'created_at' => string '2013-03-18 00:59:08' (length=19)
'updated_at' => string '2013-03-18 00:59:08' (length=19)
protected 'relations' =>
array (size=0)
empty
protected 'fillable' =>
array (size=0)
empty
protected 'guarded' =>
array (size=0)
empty
protected 'dates' =>
array (size=0)
empty
protected 'with' =>
array (size=0)
empty
public 'exists' => boolean true
object(User)[391]
protected 'table' => string 'users' (length=5)
protected 'hidden' =>
array (size=1)
0 => string 'password' (length=8)
public 'autoHashPasswordAttributes' => boolean true
public 'validationErrors' =>
object(Illuminate\Support\MessageBag)[406]
protected 'messages' =>
array (size=0)
empty
protected 'format' => string '<span class="help-inline">:message</span>' (length=41)
public 'autoHydrateEntityFromInput' => boolean false
public 'forceEntityHydrationFromInput' => boolean false
public 'autoPurgeRedundantAttributes' => boolean false
protected 'purgeFilters' =>
array (size=0)
empty
protected 'purgeFiltersInitialized' => boolean false
protected 'connection' => null
protected 'primaryKey' => string 'id' (length=2)
protected 'perPage' => int 15
public 'incrementing' => boolean true
public 'timestamps' => boolean true
protected 'attributes' =>
array (size=8)
'id' => string '1' (length=1)
'username' => string 'admin' (length=5)
'email' => string '[email protected]' (length=14)
'password' => string '$2y$08$wcSSvuDQsLF7p6WyHkPSF.QRbaqkE/a9Ro4f/taWP6Cu8GIYran8y' (length=60)
'confirmation_code' => string 'fae75df69e37b9d66cb955004fe3c4a7' (length=32)
'confirmed' => string '1' (length=1)
'created_at' => string '2013-03-18 00:59:08' (length=19)
'updated_at' => string '2013-03-18 00:59:08' (length=19)
protected 'original' =>
array (size=8)
'id' => string '1' (length=1)
'username' => string 'admin' (length=5)
'email' => string '[email protected]' (length=14)
'password' => string '$2y$08$wcSSvuDQsLF7p6WyHkPSF.QRbaqkE/a9Ro4f/taWP6Cu8GIYran8y' (length=60)
'confirmation_code' => string 'fae75df69e37b9d66cb955004fe3c4a7' (length=32)
'confirmed' => string '1' (length=1)
'created_at' => string '2013-03-18 00:59:08' (length=19)
'updated_at' => string '2013-03-18 00:59:08' (length=19)
protected 'relations' =>
array (size=0)
empty
protected 'fillable' =>
array (size=0)
empty
protected 'guarded' =>
array (size=0)
empty
protected 'dates' =>
array (size=0)
empty
protected 'with' =>
array (size=0)
empty
public 'exists' => boolean true
Granted it's through a controller not through phpunit. I don't have a test handy to test a double login at the moment.
Do you get any errors?
from confide.
i dont get any errors, it's just the second time it returns a null, how does it look when the second one is a different user?
from confide.
Ah, then it's null. We're getting somewhere now. :)
from confide.
ok so im not crazy, at least not yet :D
from confide.
Nevermind, had a typo in the password. Both users are returned. :(
from confide.
darn, does that mean I can't test on phpunit if I want to switch between users?
from confide.
that doesn't seem correct. Can you verify that the database information is being removed?
Later this week I'll be setting up test cased for my Starter Site project and that'll include logging in as user and admin. I'll be able to tell you then. (https://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site)
from confide.
Try Session::flush(); after the logout and see what happens.
from confide.
@andrew13 Session::flush not working, and I also notice that my session table is empty, does that have anything to do with it?
from confide.
Possibly, your session data table should store your user info while logged in.
from confide.
I think I figured out why, please clarify this is a Laravel bug actually.
- when I call logout it goes here: https://github.com/laravel/framework/blob/master/src/Illuminate/Auth/Guard.php#L268 and it sets $this->loggedOut = true;
- Notice that in attempt(), it doesn't set loggedOut back to false. https://github.com/laravel/framework/blob/master/src/Illuminate/Auth/Guard.php#L186
- when I call Confide::user() which in turn calls user() in Guard.php, it checks whether it's loggedOut if it is, it will return nothing. https://github.com/laravel/framework/blob/master/src/Illuminate/Auth/Guard.php#L101
from confide.
Hmm, interesting. That logic makes sense to me.
from confide.
I have confirmed that adding $this->loggedIn = true after the user is logged in fixes my problem, should I report this?
from confide.
You should add the fix to the repository and create a pull request: https://github.com/laravel/laravel/tree/develop
If you don't want to or don't know how I can for you.
from confide.
@andrew13 I think I did a pull request (my first time) laravel/framework#692. I will close this issue, thanks for your help andrew13
from confide.
Your welcome and good luck with development!
from confide.
how to make new confide:migration to make a new table in my database and use it for the signup page in my application?
from confide.
Related Issues (20)
- Too many assumptions that email implies a unique user - it seldom does in mature systems
- Serialization of 'Closure' is not allowed HOT 6
- Email subject in config HOT 2
- hash method and user data migrate
- How to set my own view for password reset? HOT 1
- Laravel 5 Support? HOT 3
- SMS registration HOT 1
- Deactivate user? HOT 2
- erroneous error: The credentials provided have already been used. Try with different credentials HOT 1
- Getting wrong confirmation code while registering with username and email id containing dot(.)
- composer update for laravel 5 does not work HOT 4
- 5.0.x-dev: Missing file 'tests/Confide/helpers.php' throws Fatal error during `artisan clear-compiled` HOT 1
- When I create file with using '$ php artisan confide:migration', that file's path is wrong.
- Username not accepting "." HOT 1
- Support for Laravel 5.1 HOT 2
- Confide 4.3 is full of bug HOT 1
- Class 'Zizaco\Confide\UserValidator' not found
- Wrong confirmation code
- Warning: Ambiguous class resolution, "ConfideSetupUsersTable"
- laravel 5.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from confide.