WordPress.org

Making WordPress.org

Changeset 10899


Ignore:
Timestamp:
04/14/2021 03:56:53 AM (8 months ago)
Author:
dd32
Message:

Login: Have users agree to abide by the Privacy Policy (and later, ToS/CoC) when registering.

Enabled for all new signups.
See #5618.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php

    r10893 r10899  
    8080 * Handles creating a "Pending" registration that will later be converted to an actual user  account.
    8181 */
    82 function wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist = false  ) {
     82function wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist = false, $tos_revision = 0  ) {
    8383    global $wpdb, $wp_hasher;
    8484
     
    9797    $profile_key        = wp_generate_password( 24, false, false );
    9898    $hashed_profile_key = time() . ':' . wp_hash_password( $profile_key );
     99
     100    $tos_meta_key = WPOrg_SSO::TOS_USER_META_KEY;
    99101
    100102    $pending_user = array(
     
    107109            'user_mailinglist' => $user_mailinglist,
    108110            'registration_ip'  => $_SERVER['REMOTE_ADDR'], // Spam & fraud control. Will be discarded after the account is created.
     111            $tos_meta_key      => $tos_revision,
    109112        ),
    110113        'scores' => array()
     
    289292    }
    290293
    291     foreach ( array( 'url', 'from', 'occ', 'interests' ) as $field ) {
     294    $tos_meta_key = WPOrg_SSO::TOS_USER_META_KEY;
     295
     296    foreach ( array( 'url', 'from', 'occ', 'interests', $tos_meta_key ) as $field ) {
    292297        if ( !empty( $pending_user['meta'][ $field ] ) ) {
    293298            $value = $pending_user['meta'][ $field ];
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php

    r10898 r10899  
    5757 */
    5858function wporg_login_replace_css() {
    59     wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons' ), '20200507' );
     59    wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons' ), '20210414' );
    6060}
    6161add_action( 'login_init', 'wporg_login_replace_css' );
     
    7373
    7474    wp_enqueue_style( 'wporg-normalize', get_template_directory_uri() . '/stylesheets/normalize.css', 3 );
    75     wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons' ), '20200507' );
     75    wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons' ), '20210414' );
    7676}
    7777add_action( 'wp_enqueue_scripts', 'wporg_login_scripts' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/register.php

    r10898 r10899  
    66 */
    77
    8 $user_login = isset( $_POST['user_login'] ) ? trim( wp_unslash( $_POST['user_login'] ) ) : '';
    9 if ( ! $user_login && !empty( WP_WPOrg_SSO::$matched_route_params['user'] ) ) {
     8$user_login       = isset( $_POST['user_login'] ) ? trim( wp_unslash( $_POST['user_login'] ) ) : '';
     9$user_email       = isset( $_POST['user_email'] ) ? trim( wp_unslash( $_POST['user_email'] ) ) : '';
     10$user_mailinglist = isset( $_POST['user_mailinglist'] ) && 'true' == $_POST['user_mailinglist'];
     11$terms_of_service = isset( $_POST['terms_of_service'] ) ? $_POST['terms_of_service'] : false;
     12
     13if ( ! $user_login && ! empty( WP_WPOrg_SSO::$matched_route_params['user'] ) ) {
    1014    $user_login = trim( WP_WPOrg_SSO::$matched_route_params['user'] );
    1115}
    12 $user_email = isset( $_POST['user_email'] ) ? trim( wp_unslash( $_POST['user_email'] ) ) : '';
    13 $user_mailinglist = isset( $_POST['user_mailinglist'] ) && 'true' == $_POST['user_mailinglist'];
    1416
    1517$error_user_login = $error_user_email = $error_recapcha_status = false;
     
    2628    }
    2729
     30    // Don't validate that it's equal to the current revision, just that they've agreed to one.
     31    // Let the post-login interstitial handle TOS updates at time of registration.
     32    $terms_of_service_error = ! $terms_of_service || $terms_of_service > TOS_REVISION;
     33
    2834    // handle user registrations.
    29     if ( ! $error_user_login && ! $error_user_email ) {
     35    if ( ! $error_user_login && ! $error_user_email && ! $terms_of_service_error ) {
    3036        if ( ! wporg_login_check_recapcha_status( 'register' ) ) {
    3137            $error_recapcha_status = true;
    3238        } else {
    33             wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist );
     39            wporg_login_create_pending_user( $user_login, $user_email, $user_mailinglist, $terms_of_service );
    3440            die();
    3541        }
     
    7985    ?>
    8086
    81     <p class="login-mailinglist">
     87    <p class="login-tos checkbox <?php if ( $terms_of_service_error ) { echo 'message error'; } ?>">
     88        <label for="terms_of_service">
     89            <input name="terms_of_service" type="checkbox" id="terms_of_service" value="<?php echo esc_attr( TOS_REVISION ); ?>" <?php checked( $terms_of_service, TOS_REVISION ); ?> required="required">
     90            <?php
     91                $localised_domain = parse_url( wporg_login_wordpress_url(), PHP_URL_HOST );
     92                printf(
     93                    __( 'I have read and accept the %s.', 'wporg' ),
     94                    wp_sprintf_l( '%l', [
     95                        "<a href='https://{$localised_domain}/about/privacy/'>" . __( 'Privacy Policy', 'wporg' ) . '</a>',
     96                        // "<a href='https://{$localised_domain}/about/terms-of-service/'>" . __( 'Terms of Service', 'wporg' ) . '</a>',
     97                        // "<a href='https://{$localised_domain}/about/code-of-conduct/'>" . __( 'Code of Conduct', 'wporg' ) . '</a>',
     98                    ] )
     99                )
     100            ?>
     101        </label>
     102    </p>
     103
     104    <p class="login-mailinglist checkbox">
    82105        <label for="user_mailinglist">
    83106            <input name="user_mailinglist" type="checkbox" id="user_mailinglist" value="true" <?php checked( $user_mailinglist, true ); ?>>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/stylesheets/login.css

    r9836 r10899  
    453453}
    454454
    455 form .login-mailinglist label {
     455form p.checkbox.error {
     456    color: #dc3232;
     457}
     458
     459form p.checkbox label {
    456460    position: relative;
    457461    display: block;
     
    461465}
    462466
    463 .rtl form .login-mailinglist label {
     467.rtl form p.checkbox label {
    464468    padding-left: 0;
    465469    padding-right: 24px;
     
    467471
    468472@media screen and (max-width: 782px) {
    469     form .login-mailinglist label {
     473    form p.checkbox label {
    470474        padding-left: 33px;
    471475    }
    472476
    473     .rtl form .login-mailinglist label {
     477    .rtl form p.checkbox label {
    474478        padding-left: 0;
    475479        padding-right: 33px;
     
    477481}
    478482
    479 form .login-mailinglist label input {
     483form p.checkbox label input {
    480484    position: absolute;
    481485    top: 0;
     
    484488}
    485489
    486 .rtl form .login-mailinglist label input {
     490.rtl form p.checkbox label input {
    487491    left: auto;
    488492    right: 0;
Note: See TracChangeset for help on using the changeset viewer.