Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug fix for logging in with username as a string.

  • Loading branch information...
commit fcd0ca87af1a117ed19fc742e67d2f6a6f327251 1 parent 6d5b77d
Merrick Christensen authored April 11, 2011

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  classes/auth/automodeler/orm.php
2  classes/auth/automodeler/orm.php
@@ -82,7 +82,7 @@ protected function _login($user, $password, $remember)
82 82
 			$username = $user;
83 83
 
84 84
 			// Load the user
85  
-			$user = new Model_User($username);
  85
+			$user = AutoModeler_ORM::factory('user')->load(db::select()->where('username', '=', $username));
86 86
 		}
87 87
 
88 88
 		// If the passwords match, perform a login

7 notes on commit fcd0ca8

Jeremy Bush

This isn't a bug. It's assumed that your user model will load entries by a unique key, like the username. Hardcoding and assuming it's going to be username in the driver isn't a good solution.

Merrick Christensen
Owner
Jeremy Bush

ORM does the same kind of thing, except it uses a dedicated method to do it: unique_key().

The difference is that I don't provide a default model for people to use.

See: https://github.com/vendo/application/blob/develop/classes/model/user.php (this is an older version that doesn't use load(), however).

Merrick Christensen
Owner
Jeremy Bush

Right, the idea is to overload the constructor of your user model to load by whatever key you want. Then you don't have to hardcode the column in the driver, where nobody can touch it really.

Merrick Christensen
Owner
Merrick Christensen
Owner

Zombor I have reverted my repository and changed the variable name from $username to $unique_key as it makes more sense since the unique key can be whatever the user specifies to overload. Thanks for your help.

Please sign in to comment.
Something went wrong with that request. Please try again.