Ejemplo n.º 1
0
 def get(self):
     client = oauth.GDIClient(application_key, application_secret, callback, self)
     username = client.get_cookie_username()
     libuser.logout(username)
     libchat.postSystemChat(username + " left the chat (log out via GDI Account)")
     client.expire_cookie()
     return self.redirect("/")
Ejemplo n.º 2
0
Archivo: main.py Proyecto: nuhajat/chat
 def get(self):
     args = dict(current_user=self.current_user,
             facebook_app_id=FACEBOOK_APP_ID)
     #client = oauth.GDIClient(application_key, application_secret, callback, self)
     #username = client.get_cookie_username()
     username = args['current_user'].name
     libuser.logout(username)
     libchat.postSystemChat(username + " left the chat")
     #client.expire_cookie()
     return self.redirect("/")
Ejemplo n.º 3
0
    def get(self, mode = ""):

        #client = pythontwitter.OAuthClient('twitter', self)       
        client = oauth.GDIClient(application_key, application_secret, callback, self)
        if mode == "login":
            return self.redirect(client.get_authorization_url())
        if mode == "verify":
            auth_token = self.request.get("oauth_token")
            auth_verifier = self.request.get("oauth_verifier")
            user_info = client.get_user_info(auth_token, auth_verifier = auth_verifier)
            return self.redirect("/")

        nickname = ""
        new_token = ""
        if client.get_cookie():
            #info = client.get('/account/verify_credentials')
            #nickname = info['screen_name']
            nickname = client.get_cookie_username()
        else:
            nickname = "__anonymous"
        
        new_token = libuser.join(nickname)

        

        #case: gw close tab, 3 menit lalu RTO, trus buka lagi, nggak ada message " has joined the chat"
        #harusnya ada message "gw has left the chat (last_updated)"
        #trus dibawahnya ada message "gw has joined the chat (waktu sekarang)"
        #penyebab: karna region dibawah ini dipanggil duluan sebelum ping
        #jadi sementara channel gw yg harusnya RTO masih ada di db, MainPage jg nambah 1 row
        #baru yaitu channel baru gw. dengan total lebih dari 1 channel, conditional statetement dibawah
        #gak bakal dieksekusi

        #gimana caranya mekanisme ping dibagian ngedelete zombie channel bisa di eksekusi lebih dulu
        #sebelum region dibawah ini jalan. solusi: pisahkan fungsi delete zombie channel di kelas ping
        #lalu panggil disini
        
        if nickname != "__anonymous":
            usr_ch_count = len(libuser.getAliveUsers(username=nickname))
            if usr_ch_count == 1:
                libchat.postSystemChat(nickname + " has joined the chat")


        

        output = template.render('index.html', {'new_nickname' : nickname, 'new_token' : new_token, 'arr_emo' : libchat.arr_emo})

        self.response.out.write(output)
Ejemplo n.º 4
0
Archivo: main.py Proyecto: nuhajat/chat
    def get(self):
        user = users.get_current_user()
        login_url = None
        if user:
            nickname = user.nickname()
        else:
            nickname = "__anonymous"
            login_url = users.create_login_url()
        new_token = libuser.join(nickname)



        #case: gw close tab, 3 menit lalu RTO, trus buka lagi, nggak ada message " has joined the chat"
        #harusnya ada message "gw has left the chat (last_updated)"
        #trus dibawahnya ada message "gw has joined the chat (waktu sekarang)"
        #penyebab: karna region dibawah ini dipanggil duluan sebelum ping
        #jadi sementara channel gw yg harusnya RTO masih ada di db, MainPage jg nambah 1 row
        #baru yaitu channel baru gw. dengan total lebih dari 1 channel, conditional statetement dibawah
        #gak bakal dieksekusi

        #gimana caranya mekanisme ping dibagian ngedelete zombie channel bisa di eksekusi lebih dulu
        #sebelum region dibawah ini jalan. solusi: pisahkan fungsi delete zombie channel di kelas ping
        #lalu panggil disini

        if nickname != "__anonymous":
            usr_ch_count = len(libuser.getAliveUsers(username=nickname))
            if usr_ch_count == 1:
                libchat.postSystemChat(nickname + " has joined the chat")




        output = template.render('index.html', {'login_url': login_url, 'new_nickname' : nickname, 'new_token' : new_token, 'arr_emo' : libchat.arr_emo, 'facebook_app_id' : FACEBOOK_APP_ID})
        self.response.headers['Access-Control-Allow-Origin'] = '*'

        self.response.out.write(output)