def check_login(*args, **kwargs): if 'token' not in args[1].params.keys(): raise RError(21) user = RAdminUser(token=args[1].params['token']) user.login_by_token() if not user.info.ifLogin: raise RError(22) func(*args, user=user, **kwargs)
def on_put(self, req, resp, code): user = RAdminUser() if 'request' not in req.context.keys(): raise RError(16) request = req.context['request'] if 'password' not in request.keys(): raise RError(20) user.reset_password(code, request['password'])
def on_post(self, req, resp, code): if 'request' not in req.context.keys(): raise RError(16) request = req.context['request'] if 'username' not in request.keys(): raise RError(20) if 'password' not in request.keys(): raise RError(20) if not re.match('^[a-z0-9A-Z_]{3,60}$', request['username']): raise RError(13) user = RAdminUser() user.register(code, request['username'], request['password'])
def on_post(self, req, resp): if 'request' not in req.context.keys(): raise RError(16) request = req.context['request'] if 'username' not in request.keys(): raise RError(20) if 'password' not in request.keys(): raise RError(20) user = RAdminUser() token = utils.generate_code(16) user.login_by_password(request['username'], request['password'], token) req.context['result'] = {'token': token, 'username': user.info.username, 'level': user.info.level}