Пример #1
0
    def verifyUser(self, username, password):
        """ verify user with password """
        res = {}
        fabric = FabricSession()
        try:
            password = self._convertPassword(password)
            user = fabric.query(UserMapping).filter(
                UserMapping.loginname == username).first()
        except Exception as e:
            pass
        finally:
            fabric.close()

        if user is None:
            res['status'] = 'error'
            res['msg'] = 'not_register'
        else:
            if password != user.password:
                res['status'] = 'error'
                res['msg'] = 'password_error'
            else:
                res['status'] = 'success'
                res['username'] = user.nickname
                res['msg'] = 'login_success'

        return res
Пример #2
0
    def delProjects(self, projects=None):
        res = {}
        if not projects:
            res['status'] = 'error'
            res['msg'] = 'not_projects'

        fabric = FabricSession()
        try:
            print(projects)
            fabric.query( ProjectMapping ).filter( ProjectMapping.id.in_(projects) ).delete(synchronize_session=False)
            fabric.commit()
            res['status'] = 'success'
            res['msg'] = 'ok'
        except Exception as e :
            res['status'] = 'exception'
            res['msg'] = str(e)
        finally:
            fabric.close()

        return res