@@ -296,18 +296,17 @@ protected function send_activation_email($user_id)
296
296
{
297
297
case USER_ACTIVATION_SELF :
298
298
$ email_template = 'user_welcome_inactive ' ;
299
- $ user_actkey = gen_rand_string (mt_rand (6 , 10 ));
300
299
break ;
301
300
case USER_ACTIVATION_ADMIN :
302
301
$ email_template = 'admin_welcome_inactive ' ;
303
- $ user_actkey = gen_rand_string (mt_rand (6 , 10 ));
304
302
break ;
305
303
default :
306
304
$ email_template = 'user_welcome ' ;
307
- $ user_actkey = '' ;
308
305
break ;
309
306
}
310
307
308
+ $ user_actkey = $ this ->get_activation_key ($ user_id );
309
+
311
310
if (!class_exists ('messenger ' ))
312
311
{
313
312
require ($ this ->phpbb_root_path . 'includes/functions_messenger. ' . $ this ->php_ext );
@@ -327,6 +326,35 @@ protected function send_activation_email($user_id)
327
326
$ messenger ->send (NOTIFY_EMAIL );
328
327
}
329
328
329
+ /**
330
+ * Get user activation key
331
+ *
332
+ * @param int $user_id User ID
333
+ *
334
+ * @return string User activation key for user
335
+ */
336
+ protected function get_activation_key (int $ user_id ): string
337
+ {
338
+ $ user_actkey = '' ;
339
+
340
+ if ($ this ->config ['require_activation ' ] == USER_ACTIVATION_SELF || $ this ->config ['require_activation ' ] == USER_ACTIVATION_ADMIN )
341
+ {
342
+ $ user_actkey = gen_rand_string (mt_rand (6 , 10 ));
343
+
344
+ $ sql_ary = [
345
+ 'user_actkey ' => $ user_actkey ,
346
+ 'user_actkey_expiration ' => \phpbb \user::get_token_expiration (),
347
+ ];
348
+
349
+ $ sql = 'UPDATE ' . USERS_TABLE . '
350
+ SET ' . $ this ->db ->sql_build_array ('UPDATE ' , $ sql_ary ) . '
351
+ WHERE user_id = ' . (int ) $ user_id ;
352
+ $ this ->db ->sql_query ($ sql );
353
+ }
354
+
355
+ return $ user_actkey ;
356
+ }
357
+
330
358
/**
331
359
* Helper to translate questions to the user
332
360
*
0 commit comments