Beispiel #1
0
def login_user(P, req):
    email = P["email"] if "email" in P else None
    password = P["password"] if "password" in P else None
    if email is None or password is None:
        return UR.prepare_response({"ckey": None})
    user = auth.checkUser(email, password)
    if user is None:
        return UR.prepare_response({"ckey": None})
    u_in = json.loads(
        urllib.unquote(
            req.COOKIES.get("userinfo", urllib.quote('{"ckey": ""}'))))
    if "ckey" in u_in and u_in["ckey"] != "" and u_in["ckey"] != user.confkey:
        #log that there's been an identity change
        auth.log_guest_login(u_in["ckey"], user.id)
    user_dict = {
        "ckey": user.confkey,
        "email": user.email,
        "firstname": user.firstname,
        "lastname": user.lastname,
        "guest": user.guest,
        "valid": user.valid,
        "id": user.id
    }
    user_dict["userinfo"] = urllib.quote(json.dumps(user_dict))
    return UR.prepare_response(
        user_dict
    )  #this is what's needed for the client to set a cookie and be authenticated as the new user !
Beispiel #2
0
def login_user(P,req):
    email = P["email"] if "email" in P else None
    password = P["password"] if "password" in P else None
    if email is None or password is None: 
        return UR.prepare_response({"ckey": None})      
    user = auth.checkUser(email, password)
    if user is None: 
        return UR.prepare_response({"ckey": None})      
    u_in        = json.loads(urllib.unquote(req.COOKIES.get("userinfo", urllib.quote('{"ckey": ""}'))))
    if "ckey" in u_in and u_in["ckey"] != "" and u_in["ckey"] != user.confkey:  
        #log that there's been an identity change
        auth.log_guest_login(u_in["ckey"], user.id)
    return UR.prepare_response({"ckey": user.confkey, "email": user.email, "firstname": user.firstname, "lastname":user.lastname, "guest": user.guest, "valid": user.valid}) #this is what's needed for the client to set a cookie and be authenticated as the new user ! 
Beispiel #3
0
def login_user(P,req):
    email = P["email"] if "email" in P else None
    password = P["password"] if "password" in P else None
    if email is None or password is None:
        return UR.prepare_response({"ckey": None})
    user = auth.checkUser(email, password)
    if user is None:
        return UR.prepare_response({"ckey": None})
    try: 
        u_in = json.loads(urllib.unquote(req.COOKIES.userinfo)).ckey
        #log that there's been an identity change
        if u_in != user.confKey:
            auth.log_guest_login(u_in, user.id)
    except: 
        pass
    user_dict = {"ckey": user.confkey, "email": user.email, 
                 "firstname": user.firstname, "lastname": user.lastname,
                 "guest": user.guest, "valid": user.valid, "id": user.id}
    user_dict["userinfo"] = urllib.quote(json.dumps(user_dict))
    return UR.prepare_response(user_dict) #this is what's needed for the client to set a cookie and be authenticated as the new user !