Example #1
0
 def upload(self):
     if Session.valid(self.__handler):
         if self.__handler.POST:
             if Session.valid(self.__handler):
                 path = current_user_path(self.__handler)
                 self.__handler.move_tmp(path)
             return 'True'
Example #2
0
 def register(self):
     if self.__handler.POST:
         username = self.__handler.get_argument('username')
         password = self.__handler.get_argument('password')
         if not Users.exists(username):
             Users.append_user(username, password)
             Session.start(self.__handler, username)
             return 'True'
         return 'False'
     else:
         return Session.valid(self.__handler)
Example #3
0
 def home(self):
     if Session.valid(self.__handler):
         name = Session.get_name(self.__handler)
         return """
             <h2>Hello</h2>
             <div class="center">
                 <section>
                     <p>Welcome %s</p>
                 </section>
             </div>
         """ % name
     return False
Example #4
0
 def login(self):
     if self.__handler.POST:
         username = self.__handler.get_argument('username')
         password = self.__handler.get_argument('password')
         if Users.exists(username):
             if Users.get_password(username) == password:
                 Session.start(self.__handler, username)
                 return 'True'
         return 'False'
     elif Session.valid(self.__handler):
         return WebData.Script.load('Home')
     return False
Example #5
0
 def validate(self):
     """
     Validate appends the clients connection to the known connections list.
     :return:
     """
     if Session.valid(self.__handler):
         SocketClients.socket_clients.append(self.__handler.connection)
         return 'True'
Example #6
0
 def logout(self):
     Session.stop(self.__handler)
     return 'True'
Example #7
0
 def refresh_script(self):
     if Session.valid(self.__handler):
         return WebData.Script.InnerMenu
     else:
         return WebData.Script.OuterMenu
Example #8
0
def current_user_path(handler):
    """
    Return the full path to the User folder.
    :param handler: the self.__handler of the Links object.
    """
    return Users.USER_PATH + Session.get_name(handler) + '/'