Exemplo n.º 1
0
def authenticate():
    error = {}

    username = local.request.form.get("username", u"")
    password = local.request.form.get("password", u"")
    
    if len(username) == 0 or len(password) == 0:
        error["length"] = "yes"
    
    if len(error) == 0:
        uid = user.authenticate(username, password)
        if uid is None:
            error["invalid"] = "yes"
    
    if len(error) == 0:
        local.session["uid"] = uid
        
        if not user.haschangedpasswd(uid):
            redirect("login.chpasswd_form")
            return

        redirect("index.index")
        return

    redirect(
        "login.form",
        **error
    )
Exemplo n.º 2
0
def chpasswd_form():
    error_match = local.request.args.get("match") != None
    error_length = local.request.args.get("length") != None
    
    first_time = not user.haschangedpasswd(local.session.get("uid"))

    template_response("/page/change_passwd.mako",
        error_match=error_match,
        error_length=error_length,
        first_time=first_time
    )