2121use App \ModelSerializers \SerializerRegistry ;
2222use Auth \Exceptions \AuthenticationException ;
2323use Auth \Exceptions \UnverifiedEmailMemberException ;
24+ use App \Services \Auth \IUserService as AuthUserService ;
2425use Exception ;
26+ use Illuminate \Http \Request as LaravelRequest ;
2527use Illuminate \Support \Facades \Request ;
2628use Illuminate \Support \Facades \Log ;
2729use Illuminate \Support \Facades \Redirect ;
@@ -86,6 +88,10 @@ final class UserController extends OpenIdController
8688 * @var IUserService
8789 */
8890 private $ user_service ;
91+ /**
92+ * @var AuthUserService
93+ */
94+ private $ auth_user_service ;
8995 /**
9096 * @var IUserActionService
9197 */
@@ -132,6 +138,7 @@ final class UserController extends OpenIdController
132138 * @param ITrustedSitesService $trusted_sites_service
133139 * @param DiscoveryController $discovery
134140 * @param IUserService $user_service
141+ * @param AuthUserService $auth_user_service
135142 * @param IUserActionService $user_action_service
136143 * @param IClientRepository $client_repository
137144 * @param IApiScopeRepository $scope_repository
@@ -150,6 +157,7 @@ public function __construct
150157 ITrustedSitesService $ trusted_sites_service ,
151158 DiscoveryController $ discovery ,
152159 IUserService $ user_service ,
160+ AuthUserService $ auth_user_service ,
153161 IUserActionService $ user_action_service ,
154162 IClientRepository $ client_repository ,
155163 IApiScopeRepository $ scope_repository ,
@@ -160,15 +168,14 @@ public function __construct
160168 LoginHintProcessStrategy $ login_hint_process_strategy
161169 )
162170 {
163-
164-
165171 $ this ->openid_memento_service = $ openid_memento_service ;
166172 $ this ->oauth2_memento_service = $ oauth2_memento_service ;
167173 $ this ->auth_service = $ auth_service ;
168174 $ this ->server_configuration_service = $ server_configuration_service ;
169175 $ this ->trusted_sites_service = $ trusted_sites_service ;
170176 $ this ->discovery = $ discovery ;
171177 $ this ->user_service = $ user_service ;
178+ $ this ->auth_user_service = $ auth_user_service ;
172179 $ this ->user_action_service = $ user_action_service ;
173180 $ this ->client_repository = $ client_repository ;
174181 $ this ->scope_repository = $ scope_repository ;
@@ -263,7 +270,8 @@ public function getAccount()
263270
264271 return $ this ->ok (
265272 [
266- 'can_login ' => $ user ->canLogin (),
273+ 'is_active ' => $ user ->isActive (),
274+ 'is_verified ' => $ user ->isEmailVerified (),
267275 'pic ' => $ user ->getPic (),
268276 'full_name ' => $ user ->getFullName (),
269277 'has_password_set ' => $ user ->hasPasswordSet (),
@@ -351,6 +359,37 @@ public function emitOTP()
351359 }
352360 }
353361
362+ /**
363+ * @return \Illuminate\Http\JsonResponse|mixed
364+ */
365+ public function resendVerificationEmail (LaravelRequest $ request )
366+ {
367+ try {
368+ $ payload = $ request ->all ();
369+ $ validator = Validator::make ($ payload , [
370+ 'email ' => 'required|string|email|max:255 '
371+ ]);
372+
373+ if (!$ validator ->passes ()) {
374+ return $ this ->error412 ($ validator ->getMessageBag ()->getMessages ());
375+ }
376+ $ this ->auth_user_service ->resendVerificationEmail ($ payload );
377+ return $ this ->ok ();
378+ }
379+ catch (ValidationException $ ex ) {
380+ Log::warning ($ ex );
381+ return $ this ->error412 ($ ex ->getMessages ());
382+ }
383+ catch (EntityNotFoundException $ ex ) {
384+ Log::warning ($ ex );
385+ return $ this ->error404 ();
386+ }
387+ catch (Exception $ ex ) {
388+ Log::error ($ ex );
389+ return $ this ->error500 ($ ex );
390+ }
391+ }
392+
354393 public function postLogin ()
355394 {
356395 $ max_login_attempts_2_show_captcha = $ this ->server_configuration_service ->getConfigValue ("MaxFailed.LoginAttempts.2ShowCaptcha " );
0 commit comments