def get_me(user_sn: int) -> UserInfo: """取得用户信息""" user_sn = webreq.principal_id if user_sn is None: busilogic.unauthorized("当前用户未验证身份") return get_user(user_sn)
def current_user(): user_sn = webreq.principal_id print(user_sn) user = get_user(user_sn) if user: return user busilogic.unauthorized()
def login(login: LoginForm): if not login.login_id : busilogic.unauthorized("登录ID不能为空") login_id = login.login_id passwd = login.passwd login = drecall(login) if not login : busilogic.unauthorized("无效登录ID:'%s'" % login_id) if not check_password(passwd, login.passwd) : busilogic.unauthorized("登录ID(%s)密码验证失败" % login_id) webreq.principal_id = str(login.user_sn) user = get_user(login.user_sn) busilogic.logger.info('User %s logged in' % user.user_name) return user