Exemple #1
0
    def test_find_user_by_id(self):
        usr1 = mimasuser.mk_MimasUser("allan", "*****@*****.**", "allanId")

        self.assertEquals(mimasuser.find_user_by_id("allanId").name(), "allan")

        usr2 = mimasuser.mk_MimasUser("paul", "*****@*****.**", "paulId")
        usr3 = mimasuser.mk_MimasUser("grisha", "*****@*****.**", "grishaId")

        self.assertEquals(mimasuser.find_user_by_id("allanId").name(), "allan")
        self.assertEquals(mimasuser.find_user_by_id("paulId").name(), "paul")
Exemple #2
0
    def test_speaker_key(self):
        usr = mimasuser.mk_MimasUser("allan", "*****@*****.**", "unique")

        s = speaker.make_new_speaker("mail@email")
        usr.set_speaker_key(s.key)

        self.assertEquals(s.key, usr.speaker_key())
Exemple #3
0
    def test_basics(self):
        usr = mimasuser.mk_MimasUser("allan", "*****@*****.**", "unique")

        self.assertEquals("allan", usr.name())
        self.assertEquals("*****@*****.**", usr.email())
        self.assertEquals(None, usr.speaker_key())
        self.assertEquals("unique", usr.unique_id())
        self.assertEquals(datetime.datetime(2017, 9, 23), usr.last_login())

        now = datetime.datetime.now()
        usr.set_last_login(now)
        self.assertEquals(now, usr.last_login())
Exemple #4
0
    def get(self):
        logging.info("Basic Google Login Success")
        google_user = users.get_current_user()
        if not google_user:
            self.redirect(users.create_login_url(self.request.uri + "loginb"))

        usr = mimasuser.find_user_by_id(google_user.user_id())
        if not usr:
            usr = mimasuser.mk_MimasUser(google_user.nickname(),
                                         google_user.email(),
                                         google_user.user_id())

        complete_login(self, usr)
Exemple #5
0
    def get(self):
        logging.info("Firebase Login Success")
        id_token = self.request.get("user")
        claims = google.oauth2.id_token.verify_firebase_token(
            id_token, HTTP_REQUEST)
        if not claims:
            logging.info("FirebaseLoginSuccess but Claims is None")
            self.redirect('/')

        usr = mimasuser.find_user_by_id(claims["user_id"])
        if not usr:
            logging.info("FirebaseLoginSuccess creating MimasUser")
            usr = mimasuser.mk_MimasUser(claims["name"], claims["email"],
                                         claims["user_id"])

        logging.info("FirebaseLoginSuccess storing login time")
        complete_login(self, usr)