'Send password reset email.'

@csrf_exempt
@validatedForm(VRatelimit(rate_ip=True, prefix='rate_password_'), user=VUserWithEmail('name'))
def POST_password(self, form, jquery, user):

    def _event(error):
        email = (user.email if user else None)
        email_verified = (bool(user.email_verified) if email else None)
        g.events.login_event('password_reset', error_msg=error, user_name=request.POST.get('name'), email=email, email_verified=email_verified, request=request, context=c)
    if form.has_errors('name', errors.USER_DOESNT_EXIST):
        _event(error='USER_DOESNT_EXIST')
    elif form.has_errors('name', errors.NO_EMAIL_FOR_USER):
        _event(error='NO_EMAIL_FOR_USER')
    elif form.has_errors('ratelimit', errors.RATELIMIT):
        _event(error='RATELIMIT')
    else:
        VRatelimit.ratelimit(rate_ip=True, prefix='rate_password_')
        if emailer.password_email(user):
            _event(error=None)
            form.set_text('.status', _("an    email    will    be    sent    to    that    account's    address    shortly"))
        else:
            _event(error='RESET_LIMIT')
            form.set_text('.status', _('try    again    tomorrow'))
