Code Duplication    Length = 13-14 lines in 2 locations

drupal/sites/default/boinc/modules/boincuser/includes/boincuser.forms.inc 1 location

@@ 59-71 (lines=13) @@
56
  $boinc_user = BoincUser::lookup_email_addr($email_addr);
57
  if (!$boinc_user) return false;
58
59
  if (password_verify($passwd_hash, $boinc_user->passwd_hash)) {
60
    // on valid login, rehash password if necessary to upgrade hash over time
61
    // as the defaults change.
62
    if (password_needs_rehash($boinc_user->passwd_hash, PASSWORD_DEFAULT)) {
63
      do_passwd_rehash($boinc_user, $passwd_hash);
64
    }
65
  } else if ($passwd_hash == $boinc_user->passwd_hash) {
66
    // if password is the legacy md5 hash, then rehash to update to
67
    // a more secure hash
68
    do_passwd_rehash($boinc_user, $passwd_hash);
69
  } else {
70
    return false;
71
  }
72
  
73
  // BOINC authentication successful; log in and synchronize accounts
74
  boincuser_login_register($boinc_user);

html/inc/user_util.inc 1 location

@@ 40-53 (lines=14) @@
37
// matches the user's passwd hash (possibly new format)
38
//
39
function check_passwd_hash($user, $passwd_hash) {
40
    if (password_verify($passwd_hash, $user->passwd_hash)) {
41
        // on valid login, rehash password to upgrade hash overtime
42
        // as the defaults change.
43
        //
44
        if (password_needs_rehash($user->passwd_hash, PASSWORD_DEFAULT)) {
45
            do_passwd_rehash($user, $passwd_hash);
46
        }
47
    } else if ($passwd_hash == $user->passwd_hash) {
48
        // user record has old format.  Change to new.
49
        //
50
        do_passwd_rehash($user, $passwd_hash);
51
    } else {
52
        return false;
53
    }
54
    return true;
55
}
56