Exemplo n.º 1
0
def fillGmailUser():
    odenki_user = OdenkiUser.loadFromSession()
    assert isinstance(odenki_user, OdenkiUser)
    try:
        gmail_user = GmailUser.loadFromSession()
    except EntityNotFound:
        gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
    assert isinstance(gmail_user, GmailUser)

    if gmail_user.odenkiId is None:
        gmail_user.odenkiId = odenki_user.odenkiId
        gmail_user.put()  # put GmailUser if odenkiId is updated
    gmail_user.saveToSession()
Exemplo n.º 2
0
def fillGmailUser():
    odenki_user = OdenkiUser.loadFromSession()
    assert isinstance(odenki_user, OdenkiUser)
    try:
        gmail_user = GmailUser.loadFromSession()
    except EntityNotFound: 
        gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
    assert isinstance(gmail_user, GmailUser)

    if gmail_user.odenkiId is None:
        gmail_user.odenkiId = odenki_user.odenkiId
        gmail_user.put() # put GmailUser if odenkiId is updated
    gmail_user.saveToSession()
Exemplo n.º 3
0
 def GET(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     
     try:
         odenki_user = OdenkiUser.loadFromSession()
         assert isinstance(odenki_user, OdenkiUser)
     except: odenki_user = None
     
     try:
         email_user = EmailUser.getByOdenkiId(odenki_user.odenkiId)
         assert isinstance(email_user, EmailUser)
     except: email_user = None
     
     try:
         twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
         assert isinstance(twitter_user, TwitterUser)
     except: twitter_user = None
     
     try:
         gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
         assert isinstance(gmail_user, GmailUser)
     except: gmail_user = None
     
     jresponse.setResultValue(odenki_user.__class__.__name__, odenki_user)
     jresponse.setResultObject(email_user)
     jresponse.setResultObject(twitter_user)
     jresponse.setResultObject(gmail_user)
     login_url = users.create_login_url("/api/auth/Gmail/RedirectedFromGoogle")
     jresponse.setResultValue("login_url", login_url)
Exemplo n.º 4
0
 def showAllGmailUsers(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     query = GmailUser.query()
     gmail_users = []
     for gmail_user in query:
         gmail_users.append(gmail_user)
     jresponse.setResult(gmail_users)
Exemplo n.º 5
0
 def deleteGmailUser(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     odenki_user = OdenkiUser.loadFromSession()
     gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
     gmail_user.key.delete_async()
     jresponse.setResultValue("OdenkiUser", odenki_user)
     jresponse.setResultValue("GmailUser", gmail_user)
Exemplo n.º 6
0
 def showAllGmailUsers(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     query = GmailUser.query()
     gmail_users = []
     for gmail_user in query:
         gmail_users.append(gmail_user)
     jresponse.setResult(gmail_users)
Exemplo n.º 7
0
 def deleteGmailUser(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     odenki_user = OdenkiUser.loadFromSession()
     gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
     gmail_user.key.delete_async()
     jresponse.setResultValue("OdenkiUser", odenki_user)
     jresponse.setResultValue("GmailUser", gmail_user)
Exemplo n.º 8
0
def fillOdenkiUserByGoogleUser():
    try:
        odenki_user = OdenkiUser.loadFromSession()
        assert isinstance(odenki_user, OdenkiUser)
        return
    except EntityNotFound:
        gmail_user = GmailUser.loadFromSession()
        assert isinstance(gmail_user, GmailUser)
        odenki_user = OdenkiUser.getByOdenkiId(gmail_user.odenkiId)
        assert isinstance(odenki_user, OdenkiUser)
        odenki_user.saveToSession()
Exemplo n.º 9
0
def fillOdenkiUserByGoogleUser():
    try:
        odenki_user = OdenkiUser.loadFromSession()
        assert isinstance(odenki_user, OdenkiUser)
        return
    except EntityNotFound:
        gmail_user = GmailUser.loadFromSession()
        assert isinstance(gmail_user, GmailUser)
        odenki_user = OdenkiUser.getByOdenkiId(gmail_user.odenkiId)
        assert isinstance(odenki_user, OdenkiUser)
        odenki_user.saveToSession()
Exemplo n.º 10
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        try:
            odenki_user = OdenkiUser.loadFromSession()
        except EntityNotFound:
            odenki_user = None

        try:
            gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
        except EntityNotFound: 
            gmail_user = None
        except AttributeError:
            gmail_user = None
        login_url = users.create_login_url("/api/auth/Gmail/RedirectedFromGoogle")
        assert isinstance(login_url, str)
        jresponse.setResultValue("OdenkiUser", odenki_user)
        jresponse.setResultValue("GmailUser", gmail_user)
        jresponse.setResultValue("login_url", login_url)
Exemplo n.º 11
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        try:
            odenki_user = OdenkiUser.loadFromSession()
        except EntityNotFound:
            odenki_user = None

        try:
            gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
        except EntityNotFound:
            gmail_user = None
        except AttributeError:
            gmail_user = None
        login_url = users.create_login_url(
            "/api/auth/Gmail/RedirectedFromGoogle")
        assert isinstance(login_url, str)
        jresponse.setResultValue("OdenkiUser", odenki_user)
        jresponse.setResultValue("GmailUser", gmail_user)
        jresponse.setResultValue("login_url", login_url)
Exemplo n.º 12
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()

        try:
            odenki_user = OdenkiUser.loadFromSession()
            assert isinstance(odenki_user, OdenkiUser)
        except:
            odenki_user = None

        try:
            email_user = EmailUser.getByOdenkiId(odenki_user.odenkiId)
            assert isinstance(email_user, EmailUser)
        except:
            email_user = None

        try:
            twitter_user = TwitterUser.getByOdenkiId(odenki_user.odenkiId)
            assert isinstance(twitter_user, TwitterUser)
        except:
            twitter_user = None

        try:
            gmail_user = GmailUser.getByOdenkiId(odenki_user.odenkiId)
            assert isinstance(gmail_user, GmailUser)
        except:
            gmail_user = None

        jresponse.setResultValue(odenki_user.__class__.__name__, odenki_user)
        jresponse.setResultObject(email_user)
        jresponse.setResultObject(twitter_user)
        jresponse.setResultObject(gmail_user)
        login_url = users.create_login_url(
            "/api/auth/Gmail/RedirectedFromGoogle")
        jresponse.setResultValue("login_url", login_url)
Exemplo n.º 13
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        jresponse.setRedirectTarget("/html/error.html")
        #jresponse.setRedirectTarget("/html/auth/index.html")
        current_user = users.get_current_user()
        if current_user is None:
            #            jresponse.setRedirectTarget("/html/auth/index.html")
            return
        #debug("type of current_user.user_id() is %s " % type(current_user.user_id()))

        # prepare GmailUser
        try:
            gmail_user = GmailUser.getByGmailId(current_user.user_id())
            gmail_user.nickname = current_user.nickname()
            gmail_user.gmail = current_user.email()
            gmail_user.put_async()
        except EntityNotFound:
            gmail_user = GmailUser()
            gmail_user.gmailId = current_user.user_id()
            gmail_user.gmail = current_user.email()
            gmail_user.nickname = current_user.nickname()
            gmail_user.put()
        assert isinstance(gmail_user, GmailUser)

        # prepare OdenkiUser
        try:
            odenki_user = OdenkiUser.loadFromSession()
        except EntityNotFound:
            odenki_user = None

        if odenki_user is None:
            if gmail_user.odenkiId is None:
                odenki_user = OdenkiUser.createNew()
                odenki_user.saveToSession()
                gmail_user.setOdenkiId(odenki_user.odenkiId)
                gmail_user.put_async()
            else:
                odenki_user = OdenkiUser.getByOdenkiId(gmail_user.odenkiId)
                odenki_user.saveToSession()
        else:
            if gmail_user.odenkiId is None:
                gmail_user.setOdenkiId(odenki_user.odenkiId)
                gmail_user.put_async()
                odenki_user.saveToSession()
            else:
                if gmail_user.odenkiId != odenki_user.odenkiId:
                    raise InconsistentAuthentiation({
                        gmail_user.__class__.__name__:
                        gmail_user,
                        odenki_user.__class__.__name__:
                        odenki_user
                    })
                odenki_user.saveToSession()

        jresponse.setResultValue("OdenkiUser", odenki_user)
        jresponse.setResultValue("GmailUser", gmail_user)
        jresponse.setRedirectTarget("/html/settings.html")
Exemplo n.º 14
0
 def deleteAllGmailUsers(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     assert jrequest.fromAdminHost
     GmailUser.deleteAll()
Exemplo n.º 15
0
    def GET(self, jrequest, jresponse):
        assert isinstance(jrequest, JsonRpcRequest)
        assert isinstance(jresponse, JsonRpcResponse)
        jresponse.setId()
        jresponse.setRedirectTarget("/html/error.html")
        #jresponse.setRedirectTarget("/html/auth/index.html")
        current_user = users.get_current_user()
        if current_user is None:
#            jresponse.setRedirectTarget("/html/auth/index.html")
            return
        #debug("type of current_user.user_id() is %s " % type(current_user.user_id()))

        # prepare GmailUser
        try:
            gmail_user = GmailUser.getByGmailId(current_user.user_id())
            gmail_user.nickname = current_user.nickname()
            gmail_user.gmail = current_user.email()
            gmail_user.put_async()
        except EntityNotFound:
            gmail_user = GmailUser()
            gmail_user.gmailId = current_user.user_id()
            gmail_user.gmail = current_user.email()
            gmail_user.nickname = current_user.nickname()
            gmail_user.put()
        assert isinstance(gmail_user, GmailUser)
        
        # prepare OdenkiUser
        try:
            odenki_user = OdenkiUser.loadFromSession()
        except EntityNotFound:
            odenki_user = None
        
        if odenki_user is None:
            if gmail_user.odenkiId is None:
                odenki_user = OdenkiUser.createNew()
                odenki_user.saveToSession()
                gmail_user.setOdenkiId(odenki_user.odenkiId)
                gmail_user.put_async()
            else:
                odenki_user = OdenkiUser.getByOdenkiId(gmail_user.odenkiId)
                odenki_user.saveToSession()
        else:
            if gmail_user.odenkiId is None:
                gmail_user.setOdenkiId(odenki_user.odenkiId)
                gmail_user.put_async()
                odenki_user.saveToSession()
            else:
                if gmail_user.odenkiId != odenki_user.odenkiId:
                    raise InconsistentAuthentiation({gmail_user.__class__.__name__: gmail_user,
                                                     odenki_user.__class__.__name__:odenki_user})
                odenki_user.saveToSession()
        
        jresponse.setResultValue("OdenkiUser", odenki_user)
        jresponse.setResultValue("GmailUser", gmail_user)
        jresponse.setRedirectTarget("/html/settings.html")
Exemplo n.º 16
0
 def deleteAllGmailUsers(self, jrequest, jresponse):
     assert isinstance(jrequest, JsonRpcRequest)
     assert isinstance(jresponse, JsonRpcResponse)
     jresponse.setId()
     assert jrequest.fromAdminHost
     GmailUser.deleteAll()