11
11
use Symfony \Component \Console \Input \InputArgument ;
12
12
use Symfony \Component \Console \Output \OutputInterface ;
13
13
use Drupal \Core \Entity \EntityTypeManagerInterface ;
14
+ use Drupal \Core \Url ;
14
15
15
16
/**
16
17
* Class UserLoginCommand.
@@ -59,6 +60,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
59
60
*/
60
61
protected function execute (InputInterface $ input , OutputInterface $ output )
61
62
{
63
+
62
64
$ user = $ input ->getArgument ('user ' );
63
65
$ userEntity = $ this ->getUserEntity ($ user );
64
66
@@ -73,7 +75,31 @@ protected function execute(InputInterface $input, OutputInterface $output)
73
75
return 1 ;
74
76
}
75
77
76
- $ url = user_pass_reset_url ($ userEntity ) . '/login ' ;
78
+ if ($ input ->hasOption ('uri ' )){
79
+ //validate if https is on uri
80
+ $ regx = '/^https:.*/s ' ;
81
+ if (preg_match ($ regx , $ input ->getOption ('uri ' ))){
82
+ $ timestamp = REQUEST_TIME ;
83
+ $ langcode = $ userEntity ->getPreferredLangcode ();
84
+ $ url = Url::fromRoute ('user.reset ' ,
85
+ [
86
+ 'uid ' => $ userEntity ->id (),
87
+ 'timestamp ' => $ timestamp ,
88
+ 'hash ' => user_pass_rehash ($ userEntity , $ timestamp ),
89
+ ],
90
+ [
91
+ 'absolute ' => TRUE ,
92
+ 'language ' => \Drupal::languageManager ()->getLanguage ($ langcode ),
93
+ 'https ' => TRUE ,
94
+ ]
95
+ )->toString ();
96
+
97
+ } else {
98
+ $ url = user_pass_reset_url ($ userEntity ) . '/login ' ;
99
+ }
100
+ } else {
101
+ $ url = user_pass_reset_url ($ userEntity ) . '/login ' ;
102
+ }
77
103
$ this ->getIo ()->success (
78
104
sprintf (
79
105
$ this ->trans ('commands.user.login.url.messages.url ' ),
0 commit comments