Skip to content

Commit 97cf92e

Browse files
author
Carlos Arroyo
committed
Added Ajax handler to UserLogin component to validate if user already exists
1 parent f8b11db commit 97cf92e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/UserLogin.php

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Validator;
66
use October\Rain\Support\ValidationException;
77
use RainLab\User\Models\Settings as UserSettings;
8+
use RainLab\User\Models\User;
89
use DMA\Friends\Classes\UserExtend;
910
use DMA\Friends\Models\Usermeta;
1011
use DMA\Friends\Wordpress\Auth as WordpressAuth;
@@ -171,6 +172,19 @@ public function onRegister()
171172
'content' => $this->makePartial('register-form', [ 'options' => $options ]),
172173
]);
173174
}
175+
176+
/**
177+
* Verify if the given user mail is not already register
178+
*/
179+
public function onAvailableUser()
180+
{
181+
$email = post('email');
182+
$data = ['available' => true];
183+
if ( User::where('email', $email)->count() > 0 ) {
184+
$data['available'] = false;
185+
}
186+
return $data;
187+
}
174188

175189
/**
176190
* Submit handler for registration

0 commit comments

Comments
 (0)