Beispiel #1
0
 def signup(self):
     if self.user_exists():
         return fx.gen_result("1","User exists")
     user = dict(
         name = self.name,
         password = fx.hash(self.password),
         email = self.email,
         user_class = self.user_class
         )
     db.users.insert(user)
     curr_dir = "data/users"+"/"+self.email+"/"
     try:
         os.mkdir(curr_dir)
     except OSError:
         pass
     return fx.gen_result("0","Signup Ok. Now you can <a href='#' onclick=\"show_box('login-box'); return false;\"> login.</a>")
Beispiel #2
0
    def authenticate(self):
        user = dict(
            email = str(self.email),
            password = fx.hash(self.password)
            )
        user = db.users.find_one(user)
        
        if not(user):
            return fx.gen_result("1","Failed")

        self.name = user["name"]
        self.email = user["email"]
        self.user_class = user["user_class"]
        data = dict(
            name = self.name,
            email = self.email,
            user_class = self.user_class 
            )
        return fx.gen_result("0", "Login ok",data)