예제 #1
0
파일: app.py 프로젝트: fred3m/toyz
 def post(self):
     """
     Load the user_id and password passed to the server from the client and 
     check authentication
     """
     user_id = self.get_argument('user_id',default='')
     pwd = self.get_argument('pwd',default='')
     if core.check_pwd(self.application.toyz_settings, user_id, pwd):
         self.set_current_user(user_id)
         self.redirect(self.get_argument('next',u'/'))
     else:
         redirect = u'/auth/login/?error='
         redirect += tornado.escape.url_escape('Invalid username or password')
         redirect += u'&next='+self.get_argument('next',u'/')
         self.redirect(redirect)
예제 #2
0
파일: app.py 프로젝트: fred3m/toyz
 def post(self):
     """
     Load the user_id and password passed to the server from the client and 
     check authentication
     """
     user_id = self.get_argument('user_id', default='')
     pwd = self.get_argument('pwd', default='')
     if core.check_pwd(self.application.toyz_settings, user_id, pwd):
         self.set_current_user(user_id)
         self.redirect(self.get_argument('next', u'/'))
     else:
         redirect = u'/auth/login/?error='
         redirect += tornado.escape.url_escape(
             'Invalid username or password')
         redirect += u'&next=' + self.get_argument('next', u'/')
         self.redirect(redirect)
예제 #3
0
파일: tasks.py 프로젝트: fred3m/toyz
def change_pwd(toyz_settings, tid, params):
    """
    Change a users password.
    
    Parameters
        - toyz_settings ( :py:class:`toyz.utils.core.ToyzSettings`): Settings for the toyz 
          application
        - tid (*string* ): Task ID of the client user running the task
        - params (*dict* ): Any parameters sent by the client (see *params* below)
    
    Params
        - current_pwd (*string* ):  Users current password. Must match the password on 
          file or an exception is raised
        - new_pwd (*string* ): New password
        - confirm_pwd (*string* ): Confirmation of the the new password. If new_pwd and 
          confirm_pwd do not match, an exception is raised
    
    Response
        - id: 'notification'
        - func: 'change_pwd'
        - msg: 'Password changed successfully'
    """
    core.check4keys(params, ['current_pwd', 'new_pwd', 'confirm_pwd'])
    if core.check_pwd(toyz_settings, tid['user_id'], params['current_pwd']):
        if params['new_pwd'] == params['confirm_pwd']:
            pwd_hash = core.encrypt_pwd(toyz_settings, params['new_pwd'])
        else:
            raise ToyzJobError("New passwords did not match")
    else:
        raise ToyzJobError("Invalid user_id or password")

    db_utils.update_param(toyz_settings.db,
                          'pwd',
                          user_id=tid['user_id'],
                          pwd=pwd_hash)

    response = {
        'id': 'notification',
        'func': 'change_pwd',
        'msg': 'Password changed successfully',
    }
    return response
예제 #4
0
파일: tasks.py 프로젝트: 0x414A/toyz
def change_pwd(toyz_settings, tid, params):
    """
    Change a users password.
    
    Parameters
        - toyz_settings ( :py:class:`toyz.utils.core.ToyzSettings`): Settings for the toyz 
          application
        - tid (*string* ): Task ID of the client user running the task
        - params (*dict* ): Any parameters sent by the client (see *params* below)
    
    Params
        - current_pwd (*string* ):  Users current password. Must match the password on 
          file or an exception is raised
        - new_pwd (*string* ): New password
        - confirm_pwd (*string* ): Confirmation of the the new password. If new_pwd and 
          confirm_pwd do not match, an exception is raised
    
    Response
        - id: 'notification'
        - func: 'change_pwd'
        - msg: 'Password changed successfully'
    """
    core.check4keys(params, ['current_pwd', 'new_pwd', 'confirm_pwd'])
    if core.check_pwd(toyz_settings, tid['user_id'], params['current_pwd']):
        if params['new_pwd'] == params['confirm_pwd']:
            pwd_hash = core.encrypt_pwd(toyz_settings, params['new_pwd'])
        else:
            raise ToyzJobError("New passwords did not match")
    else:
        raise ToyzJobError("Invalid user_id or password")
    
    db_utils.update_param(toyz_settings.db, 'pwd', user_id=tid['user_id'], pwd=pwd_hash)
    
    response = {
        'id': 'notification',
        'func': 'change_pwd',
        'msg': 'Password changed successfully',
    }
    return response