示例#1
0
文件: _base.py 项目: biddyweb/ellis
 def logged_in_username(self):
     if not hasattr(self, "_username"):
         username = self.get_secure_cookie("username")
         if username != None:
             try:
                 users.lookup_user_id(self.db_session(), username)
             except NotFound:
                 username = None
         self._username = username
     return self._username
示例#2
0
文件: _base.py 项目: vitosans/ellis
 def logged_in_username(self):
     if not hasattr(self, "_username"):
         username = self.get_secure_cookie("username")
         if username != None:
             try:
                 users.lookup_user_id(self.db_session(), username)
             except NotFound:
                 username = None
         self._username = username
     return self._username
示例#3
0
文件: _base.py 项目: biddyweb/ellis
 def get_and_check_user_id(self, username):
     if username != self.logged_in_username and \
        self.request.headers.get("NGV-API-Key", None) != settings.API_KEY:
         raise HTTPError(403, "Username doesn't match logged in username.")
     try:
         return users.lookup_user_id(self.db_session(), username)
     except NotFound:
         raise HTTPError(404, "User not found.")
示例#4
0
文件: _base.py 项目: vitosans/ellis
 def get_and_check_user_id(self, username):  # pragma: no cover
     if username != self.logged_in_username and \
        self.request.headers.get("NGV-API-Key", None) != settings.API_KEY:
         raise HTTPError(403, "Username doesn't match logged in username.")
     try:
         return users.lookup_user_id(self.db_session(), username)
     except NotFound:
         raise HTTPError(404, "User not found.")
示例#5
0
文件: users.py 项目: vitosans/ellis
 def test_lookup_user_id(self):
     self.mock_cursor.fetchone.return_value = ("1234567890abcdefg", )
     id = users.lookup_user_id(self.mock_session, "*****@*****.**")
     self.mock_session.execute.assert_called_once_with(
         ANY, {"email": "*****@*****.**"})
     self.assertEquals(id, "1234567890abcdefg")
示例#6
0
文件: users.py 项目: AiprNick/ellis
 def test_lookup_user_id(self):
     self.mock_cursor.fetchone.return_value = ("1234567890abcdefg",)
     id = users.lookup_user_id(self.mock_session, "*****@*****.**")
     self.mock_session.execute.assert_called_once_with(ANY, {"email": "*****@*****.**"})
     self.assertEquals(id, "1234567890abcdefg")