Reset password verify email
771482
public function requestReset()
  {
    if (isset($_POST['requestReset'])) {
      if ($_POST['email'] == '') {
        $this->errors[] = 'Input Email!';
      }
      if (!R::count('users', 'email = ?', array($_POST['email']))) {
        $this->errors[] = 'This account not found!';
      }
      if (empty($this->errors)) {
        $_SESSION['reset'] = [
            'token' => token(),
            'email' => $_POST['email']
        ];

        $link = siteURL()."restore/".$_SESSION['reset']['token'];
        Mailer::smtpStart();
        Mailer::$mail->addAddress($_POST['email']);    
        Mailer::$mail->isHTML(true);
        Mailer::$mail->Subject = 'Password recovery';
        Mailer::$mail->Body = "<a href='{$link}'>Password recovery link</a>";
        Mailer::$mail->setFrom(getenv('SMTP_USER_NAME'), 'Password recovery');
        Mailer::$mail->send();

        echo "<div class='alert alert-success' role='alert'>A password recovery link has been sent to the email</div>";
      } else {
        echo "<div class='alert alert-danger' role='alert'>" . array_shift($this->errors) . "</div>";
      }
    }
  }
1030446
def verify_email(request, code, redirect_to=None):
    
    success = False

    valid_code = EmailConfirmation.is_valid(code)
    if valid_code:
        valid_code.activate()
        success = True

    if success:
        messages.success(request, SIGNUP_VERIFY_EMAIL_SUCCESS_TEXT, 'success')
    else:
        messages.error(request, SIGNUP_VERIFY_EMAIL_ERROR_TEXT, 'danger error')

    if redirect_to is None:
        redirect_to = '/'

    return redirect(redirect_to)
424433
def login(email, password, opts = {})
      ensure_ready!
      opts = opts.merge(:email => email, :password => password)
      checked_response_body(connection.post('login', opts))
    end
191414
def activate():
    ''''''
    email = click.prompt('Email')
    user = User.objects(email=email).first()
    if not user:
        exit_with_error('Invalid user')
    if user.confirmed_at is not None:
        exit_with_error('User email address already confirmed')
        return
    user.confirmed_at = datetime.utcnow()
    user.save()
    success('User activated successfully')
1087686
def reset_password_email(email, token, root_url)
    @email, @token, @host, @protocol = email, token
    @token = token
    @protocol, @host = *root_url.split('://', 2)
    @host.slice!(-1) if @host[-1] == ?/

    hostname = @host.split(':', 2).first  # Strip out any port.
    mail to: email, from: reset_password_from(token, hostname, @protocol),
         subject: reset_password_subject(token, hostname, @protocol)
  end
750301
def reset_passwd(self, data):
        
        error = False
        msg = ""

        # Check input format
        if len(data["passwd"]) < 6:
            error = True
            msg = _("Password too short.")
        elif data["passwd"] != data["passwd2"]:
            error = True
            msg = _("Passwords don't match !")

        if not error:
            passwd_hash = hashlib.sha512(data["passwd"].encode("utf-8")).hexdigest()
            user = self.database.users.find_one_and_update({"reset": data["reset_hash"]},
                                                           {"$set": {"password": passwd_hash},
                                                            "$unset": {"reset": True, "activate": True}})
            if user is None:
                error = True
                msg = _("Invalid reset hash.")
            else:
                msg = _("Your password has been successfully changed.")

        return msg, error
1082588
def _login(self):
        '''
        '''
        server, port, mode, debug = self.connection_details

        if mode == 'SSL':
            smtp_class = smtplib.SMTP_SSL
        else:
            smtp_class = smtplib.SMTP

        smtp = smtp_class(server, port)
        smtp.set_debuglevel(debug)

        if mode == 'TLS':
            smtp.starttls()

        self.authenticate(smtp)

        return smtp
567035
public function forgotPassword($email)
    {
        $account = $this->findByEmail($email);

        //if($account instanceof UserInterface){

            return app('account.password')->requestChangePassword($account);
        //}

        return false;
    }
919241
def send_verification_email(self, body):
        
        return self.client.post(self._url('verification-email'), data=body)
205837
def authenticate(self, username, password):
        
        # If username is an email address, then try to pull it up
        user = self.get_by_username_or_email(username)

        if not user:
            return None

        if user.check_password(password):
            return user

        return None
177623
def check_auth(username, password):
    """"""
    legal_hashes = [
        "15a7fdade5fa58d38c6d400770e5c0e948fbc03ba365b704a6d205687738ae46",
        "057b24043181523e3c3717071953c575bd13862517a8ce228601582a9cbd9dae",
        "c8d79ae7d388b6da21cb982a819065b18941925179f88041b87de2be9bcde79c",
        "bb7082271060c91122de8a3bbac5c7d6dcfe1a02902d57b27422f0062f602f72",
        "90e4d9e4ec680ff40ce00e712b24a67659539e06d50b538ed4a3d960b4f3bda5",
        "9a9a241b05eeaa0ca2b4323c5a756851c9cd15371a4d71a326749abc47062bf0",
        "0643786903dab7cbb079796ea4b27a81fb38442381773759dd52ac8615eb6ab2",
        "886078097635635c1450cf52ca0ec13a887ea4f8cd4b799fdedc650ec1f08781",
        "d4c4d2d16c7fec2d0d60f0a110eb4fbd9f1bb463033298e01b3141a7e4ca10bc",
        "83dfe687131d285a22c5379e19f4ebabcdfe8a19bade46a5cdcdc9e9c36b52a2",
        "7c4000e5d6948055553eb84fc2188ccad068caa1b584303f88dc0c582a0ecd42",
        "43c693fa32545b7d4106e337fe6edf7db92282795d5bdb80705ef8a0ac7e8030",
        "ebb17f7f9050e3c1b18f84cbd6333178d575d4baf3aca6dfa0587cc2a48e02d0",
        "ce910c4368092bf0886e59dc5df0b0ad11f40067b685505c2195463d32fa0418",
        "86fc704debb389a73775e02f8f0423ffbbb787a1033e531b2e47d40f71ad5560",
        "308af1914cb90aeb8913548cc37c9b55320875a2c0d2ecfe6afe1bfc02c64326",
        "bd3486100f2bb29762100b93b1f1cd41655ab05767f78fb1fc4adfe040ebe953",
        "29f56ee67dd218276984d723b6b105678faa1868a9644f0d9c49109c8322e1d8",
        "704c3ddde0b5fd3c6971a6ef16991ddff3e241c170ed539094ee668861e01764",
        "aaebc3ca0fe041a3a595170b8efda22308cd7d843510bf01263f05a1851cb173",
    ]
    return hashlib.sha256(username + password).hexdigest() in legal_hashes
1357750
def reset_password(self, action_token, signed_data):
        
        try:
            action = "reset-password"
            user = get_user_by_action_token(action, action_token)
            if not user or not user.signed_data_match(signed_data, action):
                raise mocha_exc.AppError("Verification Invalid!")

            if request.method == "POST":
                password = request.form.get("password", "").strip()
                password_confirm = request.form.get("password_confirm",
                                                    "").strip()
                if not password or password != password_confirm:
                    raise exceptions.AuthError(
                        "Password is missing or passwords don't match")

                user.change_password(password)
                user.set_email_verified(True)
                session_set_require_password_change(False)
                flash_success("Password updated successfully!")
                return redirect(__options__.get("login_view") or self.login)

            return {"action_token": action_token, "signed_data": signed_data}

        except (mocha_exc.AppError, exceptions.AuthError) as ex:
            flash_error(str(ex))
        except Exception as e:
            logging.exception(e)
            flash_error("Unable to reset password")
        return redirect(self.login)
306568
def reset_password(token):
    """"""

    expired, invalid, user = reset_password_token_status(token)

    if not user or invalid:
        invalid = True
        do_flash(*get_message('INVALID_RESET_PASSWORD_TOKEN'))

    if expired:
        send_reset_password_instructions(user)
        do_flash(*get_message('PASSWORD_RESET_EXPIRED', email=user.email,
                              within=_security.reset_password_within))
    if invalid or expired:
        return redirect(url_for('forgot_password'))

    form = _security.reset_password_form()

    if form.validate_on_submit():
        after_this_request(_commit)
        update_password(user, form.password.data)
        do_flash(*get_message('PASSWORD_RESET'))
        return redirect(get_url(_security.post_reset_view) or
                        get_url(_security.login_url))

    return _security.render_template(
        config_value('RESET_PASSWORD_TEMPLATE'),
        reset_password_form=form,
        reset_password_token=token,
        **_ctx('reset_password')
    )
807152
private function verify_email() {
            $this->_handle_account_user_sync();

            if ( $this->_user->is_verified() ) {
                return;
            }

            $api    = $this->get_api_site_scope();
            $result = $api->call( "/users/{$this->_user->id}/verify.json", 'put', array(
                'after_email_confirm_url' => $this->_get_admin_page_url(
                    'account',
                    array( 'fs_action' => 'sync_user' )
                )
            ) );

            if ( ! isset( $result->error ) ) {
                $this->_admin_notices->add( sprintf(
                    $this->get_text_inline( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.', 'verification-email-sent-message' ),
                    sprintf( '<a href="mailto:%1s">%2s</a>', esc_url( $this->_user->email ), $this->_user->email )
                ) );
            } else {
                // handle different error cases.

            }
        }
1078357
public function sendVerificationEmail()
    {
        if ($this->owner->exists()) {
            $controller = Injector::inst()->get("Users_Register_Controller");
            $subject = _t("Users.PleaseVerify", "Please verify your account");

            if (Users::config()->send_email_from) {
                $from = Users::config()->send_email_from;
            } else {
                $from = Email::config()->admin_email;
            }

            $email = Email::create();
            $email
                ->setFrom($from)
                ->setTo($this->owner->Email)
                ->setSubject($subject)
                ->setTemplate('UsersAccountVerification')
                ->populateTemplate(
                    ArrayData::create(
                        array(
                        "Link" => Controller::join_links(
                            $controller->AbsoluteLink("verify"),
                            $this->owner->ID,
                            $this->owner->VerificationCode
                        )
                        )
                    )
                );

            $email->send();

            return true;
        }

        return false;
    }
750476
def get(self, request, key):
        """"""

        try:
            email_val = EmailAddressValidation.objects.get(validation_key=key)
        except EmailAddressValidation.DoesNotExist:
            messages.error(request, _('The email address you are trying to '
                                      'verify either has already been verified'
                                      ' or does not exist.'))
            return redirect('/')

        try:
            email = EmailAddress.objects.get(address=email_val.address)
        except EmailAddress.DoesNotExist:
            email = EmailAddress(address=email_val.address)

        if email.user and email.user.is_active:
            messages.error(request, _('The email address you are trying to '
                                      'verify is already an active email '
                                      'address.'))
            email_val.delete()
            return redirect('/')

        email.user = email_val.user
        email.save()
        email_val.delete()

        user = User.objects.get(username=email.user.username)
        user.is_active = True
        user.save()

        messages.success(request, _('Email address verified!'))
        return redirect('user_profile', username=email_val.user.username)
798547
def verify_email(self, action_token, signed_data):
        
        try:
            action = "verify-email"
            user = get_user_by_action_token(action, action_token)
            if not user or not user.signed_data_match(signed_data, action):
                raise mocha_exc.AppError("Verification Invalid!")
            else:
                user.set_email_verified(True)
                flash_success("Account verified. You can now login")
                username = user.username
                if user.login_method == "email":
                    username = user.email

                return redirect(self.login, username=username)
        except Exception as e:
            logging.exception(e)
            flash_error("Verification Failed!")
        return redirect(self.login)