Exemple #1
0
def user_openid_authenticate():

    #o = OpenIDManager.Response( request.GET )
    o = OpenIDManager.Response(request.args)

    #check to see if the user logged in succesfully
    if (o.is_success()):

        user_id = o.get_user_id()
        email = o.get_user_email()

        #if so check we received a viable claimed_id
        if user_id:
            try:

                session['logged_in'] = True
                #user = db.user_fetch_by_id( user_id )

                #if this is a new user add them
                #if ( not user ):
                #    db.user_insert( o.get_user_id() )
                #    user_name = None
                #else :
                #    user_name = user.user_name

                #_set_authentication_cookie( user_id, user_name  )

            except Exception, e:
                return user_error(e)

        #if they don't something has gone horribly wrong, so mop up
        else:
            _delete_authentication_cookie()
def authenticate():

    o = OpenIDManager.Response(request.GET)

    #check to see if the user logged in succesfully
    if (o.is_success()):

        user_id = o.get_user_id()

        #if so check we received a viable claimed_id
        if user_id:

            try:

                user = datadb.fetch_user_by_id(user_id)

                #if this is a new user add them
                if (not user):
                    datadb.insert_user(o.get_user_id())
                    datadb.commit()
                    user_name = None
                else:
                    user_name = user["user_name"]

                set_authentication_cookie(user_id, user_name)

            except Exception, e:
                return error(e)

        #if they don't something has gone horribly wrong, so mop up
        else:
            delete_authentication_cookie()