コード例 #1
0
ファイル: login_or_logout.py プロジェクト: tanzhixu/facedns
    def post(self):
        args = login_parser.parse_args()
        username = args['username']
        password = args['password']

        if not username or not password:
            raise UserOrPassIsNone()

        userobj = User.query.filter_by(username = username).first()

        if not userobj:
            return json_message(200, 'error', 'User is not exist')

        if not userobj.verify_password(password):
            return json_message(200, 'error', 'Password Error')

        userid = userobj.id

        data = dict(username=username,userid=userid)

        token = Token_Manager()
        token = token.generate_auth_token(data= data)


        session['token'] = token

        return json_message(200, 'message', 'Login Success')
コード例 #2
0
    def post(self):
        args = login_parser.parse_args()
        username = args['username']
        password = args['password']

        if not username or not password:
            raise UserOrPassIsNone()

        userobj = User.query.filter_by(username=username).first()

        if not userobj:
            return json_message(200, 'error', 'User is not exist')

        if not userobj.verify_password(password):
            return json_message(200, 'error', 'Password Error')

        userid = userobj.id

        data = dict(username=username, userid=userid)

        token = Token_Manager()
        token = token.generate_auth_token(data=data)

        session['token'] = token

        return json_message(200, 'message', 'Login Success')
コード例 #3
0
ファイル: dname.py プロジェクト: tanzhixu/facedns
 def delete(self):
     '''
         Delete User's Domain name
     '''
     dname_id = request.args.get('dnameid')
     if dbdel(Dname,id=dname_id):
         return json_message('200', 'message', 'Delete Success')
     else:
         return json_message('200', 'error', 'Delete Failed')
コード例 #4
0
 def delete(self):
     '''
         Delete Record
     '''
     record_id = request.args.get('record_id')
     obj = abort_if_id_doesnt_exist(Record, id=record_id)
     if obj:
         if dbdel(Record, id=record_id):
             return json_message('200', 'message', 'Delete Success')
         else:
             return json_message('200', 'error', 'Delete Failed')
     else:
         return json_message('200', 'error', 'Delete Failed')
コード例 #5
0
ファイル: record.py プロジェクト: tanzhixu/facedns
 def delete(self):
     '''
         Delete Record
     '''
     record_id = request.args.get('record_id')
     obj = abort_if_id_doesnt_exist(Record,id=record_id)
     if obj:
         if dbdel(Record,id=record_id):
             return json_message('200', 'message', 'Delete Success')
         else:
             return json_message('200', 'error', 'Delete Failed')
     else:
         return json_message('200', 'error', 'Delete Failed')
コード例 #6
0
ファイル: dname.py プロジェクト: tanzhixu/facedns
    def post(self):
        '''
            Add Domain name
        '''
        userid = request.json.get('userid')
        dname = request.json.get('dname')

        u = abort_if_userid_doesnt_exist(userid)
        d = Dname(dname=dname, user=u)

        if dbadd(d):
            return json_message(200, 'message', 'Domain name insert success')
        else:
            return json_message(200, 'error', 'Domain name insert failed')
コード例 #7
0
ファイル: record.py プロジェクト: tanzhixu/facedns
    def post(self):
        '''
            Insert domain's record
        '''
        dname_id = request.json.get('dnameid')
        record = request.json.get('record')
        type = request.json.get('type')
        value = request.json.get('value')
        ttl = request.json.get('ttl')

        dnameobj = abort_if_id_doesnt_exist(Dname,id=dname_id)
        recordobj = Record(record=record,type=type,value=value,ttl=ttl,dname=dnameobj)

        if dbadd(recordobj):
            return json_message(200, 'message', 'Record Insert Success')
        else:
            return json_message(200, 'error', 'Record Insert Failed')
コード例 #8
0
ファイル: users.py プロジェクト: tanzhixu/facedns
    def delete(self,userid):
        '''
            Delete User
        '''
        abort_if_userid_doesnt_exist(userid)

        dbdel(User, id=userid)

        return json_message(200, 'message', 'User Delete Success')
コード例 #9
0
    def delete(self, userid):
        '''
            Delete User
        '''
        abort_if_userid_doesnt_exist(userid)

        dbdel(User, id=userid)

        return json_message(200, 'message', 'User Delete Success')
コード例 #10
0
ファイル: users.py プロジェクト: tanzhixu/facedns
    def put(self,userid):
        '''
            Update user's password
        '''
        abort_if_userid_doesnt_exist(userid)

        password = request.json.get('password', None)

        if not password:
            return json_message(200, 'error', 'Password is None')

        query = db.session.query(User)
        newpasswd = pwd_context.encrypt(password)

        try:
            query.filter(User.id == userid).update({User.password_hash: newpasswd})
        except Exception:
            return json_message(200, 'error', 'Password Change Failed')

        return json_message(200, 'message', 'Password Change Success')
コード例 #11
0
    def post(self):
        '''
            Insert domain's record
        '''
        dname_id = request.json.get('dnameid')
        record = request.json.get('record')
        type = request.json.get('type')
        value = request.json.get('value')
        ttl = request.json.get('ttl')

        dnameobj = abort_if_id_doesnt_exist(Dname, id=dname_id)
        recordobj = Record(record=record,
                           type=type,
                           value=value,
                           ttl=ttl,
                           dname=dnameobj)

        if dbadd(recordobj):
            return json_message(200, 'message', 'Record Insert Success')
        else:
            return json_message(200, 'error', 'Record Insert Failed')
コード例 #12
0
    def put(self, userid):
        '''
            Update user's password
        '''
        abort_if_userid_doesnt_exist(userid)

        password = request.json.get('password', None)

        if not password:
            return json_message(200, 'error', 'Password is None')

        query = db.session.query(User)
        newpasswd = pwd_context.encrypt(password)

        try:
            query.filter(User.id == userid).update(
                {User.password_hash: newpasswd})
        except Exception:
            return json_message(200, 'error', 'Password Change Failed')

        return json_message(200, 'message', 'Password Change Success')
コード例 #13
0
ファイル: users.py プロジェクト: tanzhixu/facedns
    def post(self):
        '''
            User Register
        '''
        args = login_parser.parse_args()
        username = args['username']
        password = args['password']

        if not username or not password:
            raise UserOrPassIsNone()

        if User.query.filter_by(username=username).first() is not None:
            return abort(409)

        userobj = User(username=username)
        userobj.hash_password(password)
        dbadd(userobj)

        return json_message(200, 'message', 'User Register Success')
コード例 #14
0
    def post(self):
        '''
            User Register
        '''
        args = login_parser.parse_args()
        username = args['username']
        password = args['password']

        if not username or not password:
            raise UserOrPassIsNone()

        if User.query.filter_by(username=username).first() is not None:
            return abort(409)

        userobj = User(username=username)
        userobj.hash_password(password)
        dbadd(userobj)

        return json_message(200, 'message', 'User Register Success')
コード例 #15
0
ファイル: login_or_logout.py プロジェクト: tanzhixu/facedns
    def get(self):
        session.clear()

        return json_message(200, 'message', 'Logout Sucess')
コード例 #16
0
    def get(self):
        session.clear()

        return json_message(200, 'message', 'Logout Sucess')