예제 #1
0
파일: urls.py 프로젝트: excelle08/Umbrella
def register_user():
    i = ctx.request.input(name="", email="", password="", captcha="")
    username = valid_secure_data(i.name.strip())
    email = valid_secure_data(i.email.strip().lower())
    password = i.password.strip()
    captcha = i.captcha.strip()
    try:
        user = user_register(email, password, username, captcha, ctx.captcha)
    except APIValueError, ex:
        raise ex
예제 #2
0
파일: urls.py 프로젝트: excelle08/Umbrella
def send_message():
    i = ctx.request.input(to="", subject="", content="")
    user_to = User.find_first("where t_emailaddr=?", i.to)
    to_id = user_to.t_uid
    from_id = ctx.request.user.t_uid
    subject = valid_secure_data(i.subject)
    content = valid_secure_data(i.content)
    msg = Message(t_to=to_id, t_from=from_id, t_title=subject, t_content=content, t_read=0, t_time=time.time())
    msg.insert()
    return dict()
예제 #3
0
파일: urls.py 프로젝트: excelle08/Umbrella
def edit_username():
    i = ctx.request.input()
    new_username = valid_secure_data(i.username)
    user = ctx.request.user
    user.username = new_username
    user.update()
    return user
예제 #4
0
파일: urls.py 프로젝트: excelle08/Umbrella
def api_add_friend():
    current_user = ctx.request.user
    current_peerlist = PeerList.find_first("where t_uid=?", current_user.t_uid)
    i = ctx.request.input(email="")
    target_email = valid_secure_data(i.email)
    if not target_email:
        raise APIValueError("email", "Empty email address")
    target_user = User.find_first("where t_emailaddr=?", target_email)
    if target_user is None:
        raise APIValueError("email", "User doesn't exist.")
    current_peerlist.t_friends += ";" + str(target_user.t_uid)
    current_peerlist.update()
    return dict()