def check_password(self): user = zikebase.User(self.ds, ID=1) zikebase.load("Password") assert isinstance(user.password, zikebase.Password), \ "user.password doesn't return a Password object" assert user.password == "password", \ "user.password doesn't work right"
class UserAuth(sixthday.Auth): zikebase.load("User") userClass = zikebase.User def __init__(self, sess, ds): """ usage: auth=UserAuth(sess) """ self._sess = sess self._ds = ds def fetch(self, key): if key: self.user = self.userClass(self._ds, ID=key) else: self.user = None def validate(self, dict): key = None user = None if dict.has_key("username"): try: user = self.userClass(self._ds, username=dict["username"]) except: pass elif dict.has_key("email"): try: user = self.userClass(self._ds, email=dict["email"]) except: pass if user and (user.password == dict.get("password")): key = user.ID return key
""" """ __ver__="$Id$" import weblib, zebra, zikebase, zikeplan zikebase.load("AdminApp") class ZikePlanAdminApp(zikebase.AdminApp): __super = zikebase.AdminApp ## constructor page ################################## def __init__(self, input=None): self.__super.__init__(self, input) self.what = { "goal":zikeplan.Goal, "status":zikeplan.Status, "type":zikeplan.Type, } ## home page ######################################## def act_(self): self.do("list", what="goal") def enter(self): import zebra print zebra.fetch("dsp_head") def exit(self):
""" User.py - user object for zikebase $Id$ """ import zikebase zikebase.load("Password") zikebase.load("Contact") import zdc #@TODO: refactor all this nonsense into MultiTableRecordObject! class User(zikebase.Contact): __super = zikebase.Contact passwordClass = zikebase.Password _links = { #@TODO: this doesn't seem to be working.. "contacts": [zdc.LinkSet, zikebase.Contact, "userID"], } def _new(self): self.__super._new(self) self._userRec = zdc.Table(self._ds, "base_user").new() def getEditableAttrs(self): return self.__super.getEditableAttrs(self) \ + ['username', 'password', 'uid'] def _fetch(self, key=None, **kw): keys = kw.keys() if len(keys) > 1:
""" authentication / signup process for linkwatcher """ __ver__ = "$Id$" import weblib, zebra, zdc, zikebase, linkwatcher zikebase.load("UserApp") class LWUserApp(zikebase.UserApp): __super = zikebase.UserApp userClass = linkwatcher.LWUser if __name__ == "__main__": LWUserApp().act()
""" authentication / signup process for linkwatcher """ __ver__="$Id$" import weblib, zebra, zdc, zikebase,linkwatcher zikebase.load("UserApp") class LWUserApp(zikebase.UserApp): __super = zikebase.UserApp userClass = linkwatcher.LWUser if __name__=="__main__": LWUserApp().act()
""" A password class with with VERY weak "encryption" $Id$ """ import zikebase zikebase.load("Password") class Rot13Password(zikebase.Password): """ Use this if you want to EASILY decrypt someone's password (perhaps to send people their plaintext password via email).. examples: >>> import zikebase >>> pw = zikebase.Rot13Password() >>> pw.set('my password') >>> pw.crytped zikebase.Rot13Password('zl cnffjbeq') >>> zikebase.Rot13Password().crypt('zl cnffjbeq') 'my password' """ def __repr__(self): if self.crypted: return "zikebase.Rot13Password('%s')" % self.crypted else: return "zikebase.Rot13Password()" ## public methods ############################
""" A password class with with VERY weak "encryption" $Id$ """ import zikebase zikebase.load("Password") class Rot13Password(zikebase.Password): """ Use this if you want to EASILY decrypt someone's password (perhaps to send people their plaintext password via email).. examples: >>> import zikebase >>> pw = zikebase.Rot13Password() >>> pw.set('my password') >>> pw.crytped zikebase.Rot13Password('zl cnffjbeq') >>> zikebase.Rot13Password().crypt('zl cnffjbeq') 'my password' """ def __repr__(self): if self.crypted: return "zikebase.Rot13Password('%s')" % self.crypted else: return "zikebase.Rot13Password()"