Ejemplo n.º 1
0
def reset_password(current_user, email, new_password=""):
    the_user = _get_user(email, current_user)

    if new_password:
        the_user.seal = serialize_seal(seal(new_password))
    else:
        the_user.seal = None

    the_user.save()

    return "Success! Password for %s succesfully reset." % _user_to_str(the_user)
Ejemplo n.º 2
0
def create_user(email, password="", account_type="student"):
    new_user = User(email=email, account_type=account_type)

    if password:
        new_user.seal = serialize_seal(seal(password))

    try:
        new_user.save(force_insert=True)
    except OperationError:
        raise UserError("A user with that email already exists.")

    return "Success! %s created." % _user_to_str(new_user)
Ejemplo n.º 3
0
def reset_password(current_user, email, new_password=""):
    the_user = _get_user(email, current_user)

    if new_password:
        the_user.seal = serialize_seal(seal(new_password))
    else:
        the_user.seal = None

    the_user.save()

    return "Success! Password for %s succesfully reset." \
                % _user_to_str(the_user)
Ejemplo n.º 4
0
def create_user(email, password="", account_type="student"):
    new_user = User(email=email, account_type=account_type)

    if password:
        new_user.seal = serialize_seal(seal(password))

    try:
        new_user.save(force_insert=True)
    except OperationError:
        raise UserError("A user with that email already exists.")

    return "Success! %s created." % _user_to_str(new_user)
Ejemplo n.º 5
0
def reset_password(current_user, email, new_password = ""):
    the_user = _get_user(email, current_user)

    if current_user.account_type != "admin" and \
            current_user.email != the_user.email:
        raise UserError("Only admins can set other user's password.")

    if new_password:
        the_user.seal = serialize_seal(seal(new_password))
    else:
        the_user.seal = None

    the_user.save()

    return "Success! Password for %s succesfully reset." \
                % _user_to_str(the_user)
Ejemplo n.º 6
0
def reset_password(current_user, email, new_password=""):
    the_user = _get_user(email, current_user)

    if current_user.account_type != "admin" and \
            current_user.email != the_user.email:
        raise UserError("Only admins can set other user's password.")

    if new_password:
        the_user.seal = serialize_seal(seal(new_password))
    else:
        the_user.seal = None

    the_user.save()

    return "Success! Password for %s succesfully reset." \
                % _user_to_str(the_user)