@@ -362,79 +362,78 @@ feature -- Handler
362
362
l_captcha_passed : BOOLEAN
363
363
l_email : READABLE_STRING_ 8
364
364
do
365
- create {GENERIC_VIEW_CMS_RESPONSE } r .make (req , res , api )
366
- if r .has_permission (" account register" ) then
367
- if req .is_post_request_method then
368
- if
369
- attached {WSF_STRING } req .form_parameter (" name" ) as l_name and then
370
- attached {WSF_STRING } req .form_parameter (" password" ) as l_password and then
371
- attached {WSF_STRING } req .form_parameter (" email" ) as p_email and then
372
- attached {WSF_STRING } req .form_parameter (" personal_information" ) as l_personal_information
373
- then
374
- if p_email .value .is_valid_as_string_ 8 then
375
- l_email := p_email .value .to_string_ 8
376
- l_user_api := api .user_api
377
- if attached l_user_api .user_by_name (l_name .value ) or else attached l_user_api .temp_user_by_name (l_name .value ) then
378
- -- Username already exist.
379
- r .set_value (" User name already exists!" , " error_name" )
380
- l_exist := True
381
- end
382
- if attached l_user_api .user_by_email (l_email ) or else attached l_user_api .temp_user_by_email (l_email ) then
383
- -- Email already exists.
384
- r .set_value (" An account is already associated with that email address!" , " error_email" )
385
- l_exist := True
386
- end
387
- if attached recaptcha_secret_key (api ) as l_recaptcha_key then
388
- if attached {WSF_STRING } req .form_parameter (" g-recaptcha-response" ) as l_recaptcha_response and then is_captcha_verified (l_recaptcha_key , l_recaptcha_response .url_encoded_value ) then
389
- l_captcha_passed := True
390
- else
391
- -- | Bad or missing captcha
392
- l_captcha_passed := False
393
- end
394
- else
395
- -- | reCaptcha is not setup, so no verification
365
+ if
366
+ api .has_permission (" account register" ) and then
367
+ req .is_post_request_method
368
+ then
369
+ create {GENERIC_VIEW_CMS_RESPONSE } r .make (req , res , api )
370
+ if
371
+ attached {WSF_STRING } req .form_parameter (" name" ) as l_name and then
372
+ attached {WSF_STRING } req .form_parameter (" password" ) as l_password and then
373
+ attached {WSF_STRING } req .form_parameter (" email" ) as p_email and then
374
+ attached {WSF_STRING } req .form_parameter (" personal_information" ) as l_personal_information
375
+ then
376
+ if p_email .value .is_valid_as_string_ 8 then
377
+ l_email := p_email .value .to_string_ 8
378
+ l_user_api := api .user_api
379
+ if attached l_user_api .user_by_name (l_name .value ) or else attached l_user_api .temp_user_by_name (l_name .value ) then
380
+ -- Username already exist.
381
+ r .set_value (" User name already exists!" , " error_name" )
382
+ l_exist := True
383
+ end
384
+ if attached l_user_api .user_by_email (l_email ) or else attached l_user_api .temp_user_by_email (l_email ) then
385
+ -- Email already exists.
386
+ r .set_value (" An account is already associated with that email address!" , " error_email" )
387
+ l_exist := True
388
+ end
389
+ if attached recaptcha_secret_key (api ) as l_recaptcha_key then
390
+ if attached {WSF_STRING } req .form_parameter (" g-recaptcha-response" ) as l_recaptcha_response and then is_captcha_verified (l_recaptcha_key , l_recaptcha_response .url_encoded_value ) then
396
391
l_captcha_passed := True
397
- end
398
- if not l_exist then
399
- -- New temp user
400
- create u .make (l_name .value )
401
- u .set_email (l_email )
402
- u .set_password (l_password .value )
403
- u .set_personal_information (l_personal_information .value )
404
- l_user_api .new_temp_user (u )
405
-
406
- -- Create activation token
407
- l_token := new_token
408
- l_user_api .new_activation (l_token , u .id )
409
- l_url_activate := req .absolute_script_url (" /account/activate/" + l_token )
410
- l_url_reject := req .absolute_script_url (" /account/reject/" + l_token )
411
-
412
- -- Send Email to webmaster
413
- create es .make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS }.make (api ))
414
- write_debug_log (generator + " .handle register: send_register_email" )
415
- es .send_account_evaluation (u , l_personal_information .value , l_url_activate , l_url_reject , req .absolute_script_url (" " ))
416
-
417
- -- Send Email to user
418
- create es .make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS }.make (api ))
419
- write_debug_log (generator + " .handle register: send_contact_email" )
420
- es .send_contact_email (l_email , u , req .absolute_script_url (" " ))
421
392
else
422
- r .set_value (l_name .value , " name" )
423
- r .set_value (l_email , " email" )
424
- r .set_value (l_personal_information .value , " personal_information" )
425
- r .set_status_code ({HTTP_CONSTANTS }.bad_request )
393
+ -- | Bad or missing captcha
394
+ l_captcha_passed := False
426
395
end
396
+ else
397
+ -- | reCaptcha is not setup, so no verification
398
+ l_captcha_passed := True
399
+ end
400
+ if not l_exist then
401
+ -- New temp user
402
+ create u .make (l_name .value )
403
+ u .set_email (l_email )
404
+ u .set_password (l_password .value )
405
+ u .set_personal_information (l_personal_information .value )
406
+ l_user_api .new_temp_user (u )
407
+ -- Create activation token
408
+ l_token := new_token
409
+ l_user_api .new_activation (l_token , u .id )
410
+ l_url_activate := req .absolute_script_url (" /account/activate/" + l_token )
411
+ l_url_reject := req .absolute_script_url (" /account/reject/" + l_token )
412
+ -- Send Email to webmaster
413
+ create es .make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS }.make (api ))
414
+ write_debug_log (generator + " .handle register: send_register_email" )
415
+ es .send_account_evaluation (u , l_personal_information .value , l_url_activate , l_url_reject , req .absolute_script_url (" " ))
416
+
417
+ -- Send Email to user
418
+ create es .make (create {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS }.make (api ))
419
+ write_debug_log (generator + " .handle register: send_contact_email" )
420
+ es .send_contact_email (l_email , u , req .absolute_script_url (" " ))
427
421
else
428
422
r .set_value (l_name .value , " name" )
429
- r .set_value (p_email . value , " email" )
423
+ r .set_value (l_email , " email" )
430
424
r .set_value (l_personal_information .value , " personal_information" )
431
425
r .set_status_code ({HTTP_CONSTANTS }.bad_request )
432
426
end
433
427
else
434
- api .response_api .send_bad_request (" There were issue with your application, invalid or missing values." , req , res )
428
+ r .set_value (l_name .value , " name" )
429
+ r .set_value (p_email .value , " email" )
430
+ r .set_value (l_personal_information .value , " personal_information" )
431
+ r .set_status_code ({HTTP_CONSTANTS }.bad_request )
435
432
end
433
+ r .execute
434
+ else
435
+ api .response_api .send_bad_request (" There were issue with your application, invalid or missing values." , req , res )
436
436
end
437
- r .execute
438
437
else
439
438
api .response_api .send_permissions_access_denied (" You can also contact the webmaster to ask for an account." , Void , req , res )
440
439
end
0 commit comments