]> git.mxchange.org Git - friendica.git/commitdiff
Ability to enter a password when the first user is created
authorMichael Vogel <icarus@dabo.de>
Tue, 30 Jun 2015 21:37:31 +0000 (23:37 +0200)
committerMichael Vogel <icarus@dabo.de>
Tue, 30 Jun 2015 21:37:31 +0000 (23:37 +0200)
include/user.php
mod/register.php
view/templates/register.tpl

index f8b1578ceb188d0ed3050c3c581baf809c70fb88..580af56f981ac21bf790021959c31b4b613fe148 100644 (file)
@@ -27,12 +27,20 @@ function create_user($arr) {
        $openid_url = ((x($arr,'openid_url')) ? notags(trim($arr['openid_url'])) : '');
        $photo      = ((x($arr,'photo'))      ? notags(trim($arr['photo']))      : '');
        $password   = ((x($arr,'password'))   ? trim($arr['password'])           : '');
+       $password1  = ((x($arr,'password1'))  ? trim($arr['password1'])          : '');
+       $confirm    = ((x($arr,'confirm'))    ? trim($arr['confirm'])            : '');
        $blocked    = ((x($arr,'blocked'))    ? intval($arr['blocked'])  : 0);
        $verified   = ((x($arr,'verified'))   ? intval($arr['verified']) : 0);
 
        $publish    = ((x($arr,'profile_publish_reg') && intval($arr['profile_publish_reg'])) ? 1 : 0);
        $netpublish = ((strlen(get_config('system','directory_submit_url'))) ? $publish : 0);
 
+       if ($password1 != $confirm) {
+               $result['message'] .= t('Passwords do not match. Password unchanged.') . EOL;
+               return $result;
+       } elseif ($password1 != "")
+               $password = $password1;
+
        $tmp_str = $openid_url;
 
        if($using_invites) {
index 4c0860e6e3f3362a9ace2b2a732886114e95a85b..f8e970855edfea1286ce2e5632f42632bb3f9587 100644 (file)
@@ -79,25 +79,27 @@ function register_post(&$a) {
                        set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
                }
 
-               $res = send_register_open_eml(
-                       $user['email'],
-                       $a->config['sitename'],
-                       $a->get_baseurl(),
-                       $user['username'],
-                       $result['password']);
-
-               if($res) {
-                       info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
-                       goaway(z_root());
-               }
-               else {
-                       notice(
-                               sprintf(
-                                       t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.'),
-                                        $user['email'],
-                                        $result['password']
-                                        ). EOL
-                       );
+               // Only send a password mail when the password wasn't manually provided
+               if (!x($_POST,'password1') OR !x($_POST,'confirm')) {
+                       $res = send_register_open_eml(
+                               $user['email'],
+                               $a->config['sitename'],
+                               $a->get_baseurl(),
+                               $user['username'],
+                               $result['password']);
+
+                       if($res) {
+                               info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
+                               goaway(z_root());
+                       } else {
+                               notice(
+                                       sprintf(
+                                               t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.'),
+                                                $user['email'],
+                                                $result['password']
+                                                ). EOL
+                               );
+                       }
                }
        }
        elseif($a->config['register_policy'] == REGISTER_APPROVE) {
@@ -235,6 +237,9 @@ function register_content(&$a) {
                ));
        }
 
+       $r = q("SELECT count(*) AS `contacts` FROM `contact`");
+       $passwords = !$r[0]["contacts"];
+
        $license = '';
 
        $o = get_markup_template("register.tpl");
@@ -262,6 +267,9 @@ function register_content(&$a) {
                '$openid'    => $openid_url,
                '$namelabel' => t('Your Full Name ' . "\x28" . 'e.g. Joe Smith' . "\x29" . ': '),
                '$addrlabel' => t('Your Email Address: '),
+               '$passwords' => $passwords,
+               '$password1' => array('password1', t('New Password:'), '', ''),
+               '$password2' => array('confirm', t('Confirm:'), '', ''),
                '$nickdesc'  => str_replace('$sitename',$a->get_hostname(),t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@$sitename</strong>\'.')),
                '$nicklabel' => t('Choose a nickname: '),
                '$photo'     => $photo,
index 8a941145ab8b4268226cce6625670d1612d67d1f..dfc35736161dbe687a490e53e6a1050fadc58db4 100644 (file)
        </div>
        <div id="register-email-end" ></div>
 
+{{if $passwords}}
+       {{include file="field_password.tpl" field=$password1}}
+       {{include file="field_password.tpl" field=$password2}}
+{{/if}}
+
        <p id="register-nickname-desc" >{{$nickdesc}}</p>
 
        <div id="register-nickname-wrapper" >