autoregister returns the new user on success (not just true)
This commit is contained in:
parent
21603f0225
commit
b9562cbb18
|
@ -70,7 +70,7 @@ abstract class AuthenticationPlugin extends Plugin
|
||||||
* Automatically register a user when they attempt to login with valid credentials.
|
* Automatically register a user when they attempt to login with valid credentials.
|
||||||
* User::register($data) is a very useful method for this implementation
|
* User::register($data) is a very useful method for this implementation
|
||||||
* @param username
|
* @param username
|
||||||
* @return boolean true if the user was created, false if not
|
* @return mixed instance of User, or false (if user couldn't be created)
|
||||||
*/
|
*/
|
||||||
function autoRegister($username)
|
function autoRegister($username)
|
||||||
{
|
{
|
||||||
|
@ -134,15 +134,18 @@ abstract class AuthenticationPlugin extends Plugin
|
||||||
}else{
|
}else{
|
||||||
if($this->autoregistration){
|
if($this->autoregistration){
|
||||||
$authenticated = $this->checkPassword($nickname, $password);
|
$authenticated = $this->checkPassword($nickname, $password);
|
||||||
if($authenticated && $this->autoregister($nickname)){
|
if($authenticated){
|
||||||
$authenticatedUser = User::staticGet('nickname', $nickname);
|
$user = $this->autoregister($nickname);
|
||||||
$user_username = new User_username();
|
if($user){
|
||||||
$user_username->user_id = $authenticatedUser->id;
|
$authenticatedUser = $user;
|
||||||
$user_username->provider_name = $this->provider_name;
|
$user_username = new User_username();
|
||||||
$user_username->username = $nickname;
|
$user_username->user_id = $authenticatedUser->id;
|
||||||
$user_username->created = DB_DataObject_Cast::dateTime();
|
$user_username->provider_name = $this->provider_name;
|
||||||
$user_username->insert();
|
$user_username->username = $nickname;
|
||||||
return false;
|
$user_username->created = DB_DataObject_Cast::dateTime();
|
||||||
|
$user_username->insert();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user