Example #1
0
def user_forgot(token=None):
  if not config.CONFIG_DB.has_email_authentication:
    flask.abort(418)

  form = auth.form_with_recaptcha(UserForgotForm(obj=auth.current_user_db()))
  if form.validate_on_submit():
    cache.bump_auth_attempt()
    email = form.email.data
    user_dbs, cursors = util.get_dbs(
        model.User.query(), email=email, active=True, limit=2,
      )
    count = len(user_dbs)
    if count == 1:
      task.reset_password_notification(user_dbs[0])
      return flask.redirect(flask.url_for('welcome'))
    elif count == 0:
      form.email.errors.append('This email was not found')
    elif count == 2:
      task.email_conflict_notification(email)
      form.email.errors.append(
          '''We are sorry but it looks like there is a conflict with your
          account. Our support team is already informed and we will get back to
          you as soon as possible.'''
        )

  if form.errors:
    cache.bump_auth_attempt()

  return flask.render_template(
      'user/user_forgot.html',
      title=_('Forgot Password?'),
      html_class='user-forgot',
      form=form,
    )
Example #2
0
def get_user_db_from_email(email, password):
  user_dbs, cursors = model.User.get_dbs(email=email, active=True, limit=2)
  if not user_dbs:
    return None
  if len(user_dbs) > 1:
    flask.flash('''We are sorry but it looks like there is a conflict with
        your account. Our support team is already informed and we will get
        back to you as soon as possible.''', category='danger')
    task.email_conflict_notification(email)
    return False

  user_db = user_dbs[0]
  if user_db.password_hash == util.password_hash(user_db, password):
    return user_db
  return None
Example #3
0
def get_user_db_from_email(email, password):
  user_dbs, cursors = model.User.get_dbs(email=email, active=True, limit=2)
  if not user_dbs:
    return None
  if len(user_dbs) > 1:
    flask.flash('''We are sorry but it looks like there is a conflict with
        your account. Our support team is already informed and we will get
        back to you as soon as possible.''', category='danger')
    task.email_conflict_notification(email)
    return False

  user_db = user_dbs[0]
  if user_db.password_hash == util.password_hash(user_db, password):
    return user_db
  return None
Example #4
0
def user_forgot(token=None):
    if not config.CONFIG_DB.has_email_authentication:
        flask.abort(418)

    form = auth.form_with_recaptcha(UserForgotForm(obj=auth.current_user_db()))
    if form.validate_on_submit():
        cache.bump_auth_attempt()
        email = form.email.data
        user_dbs, _ = util.get_dbs(
            model.User.query(),
            email=email,
            active=True,
            limit=2,
        )
        count = len(user_dbs)
        if count == 1:
            task.reset_password_notification(user_dbs[0])
            return flask.redirect(flask.url_for('welcome'))
        elif count == 0:
            form.email.errors.append(u'Имэйл хаяг олдсонгүй')
        elif count == 2:
            task.email_conflict_notification(email)
            form.email.errors.append(
                u'''Уучлаарай таны дансанд давхардал үүссэн байна. Бид нэн даруй хариуцсан
                ажилтанд мэдэгдсэн болно. Тусламжийн ажилтан тантай аль болох хурдан
                холбогдох болно.''')

    if form.errors:
        cache.bump_auth_attempt()

    return flask.render_template(
        'user/user_forgot.html',
        title=u'Нууц үгээ мартсан уу?',
        html_class='user-forgot',
        form=form,
    )