def login_qt_pwd_handler(r): qt = r.d.qt pwd = r.d.pwd user = User.authenticate(qt, None, pwd) return Auth.get_login_token(user)
def post(request): """ POST /api/user/token 登录获取token """ user = User.authenticate(**request.d.dict()) return Auth.get_login_token(user)
def find_pwd_code_handler(r): phone = r.phone pwd = r.d.pwd user = User.get_by_phone(phone) user.modify_password(pwd) return Auth.get_login_token(user)
def get(r): code = r.d.code data = Weixin.code2session(code) openid = data['openid'] session_key = data['session_key'] user = User.get_or_create(openid) return Auth.get_login_token(user, session_key=session_key)
def post(r): """ POST /api/user/ 创建用户 """ code = r.d.code password = r.d.password phone = SendMobile.check_captcha(r, code) user = User.create(phone, password) return Auth.get_login_token(user)
def post(request): """ POST /api/user/ 创建用户 """ invite_code = request.d.invite_code if invite_code is not None: # print(invite_code) user = User.create_invite(**request.d.dict()) else: user = User.create(**request.d.dict('username', 'password')) return Auth.get_login_token(user)
def post(r): """POST /user/oauth 打通齐天簿OAuth """ code = r.d.code data = qt_manager.get_token(code) qt_token = data['token'] qt_user_app_id = data['user_app_id'] user = User.create(qt_user_app_id, qt_token) user.update() return Auth.get_login_token(user)
def post(r): """ POST /api/user/token 登录获取token """ password = r.d.password login_type = Session.load(r, SendMobile.LOGIN_TYPE, once_delete=False) if not login_type: raise SessionError.SESSION login_value = Session.load(r, login_type, once_delete=False) if not login_value: raise SessionError.SESSION if login_type == SendMobile.PHONE_NUMBER: user = User.authenticate(None, login_value, password) else: user = User.authenticate(login_value, None, password) return Auth.get_login_token(user)
def get(r): code = r.d.code body = qt_manager.get_token(code) token = body['token'] qt_user_app_id = body['user_app_id'] user = User.create(qt_user_app_id, token) try: Resource.get_root_folder(user) except E as e: if e.eis(ResourceError.GET_ROOT_FOLDER): root = Resource.get_by_pk(Resource.ROOT_ID) Resource.create_folder(user.qt_user_app_id, user, root, ROOT_DESC) user.update() return Auth.get_login_token(user)
def get(r): """生成邀请""" return Auth.get_invite_ticket(r.spaceman)
def get(r): if r.d.secret_key == SECRET_KEY: user = User.get(r.d.user_id) return Auth.get_login_token(user, session_key='null') return ''
def register_code_handler(r): phone = r.phone pwd = r.d.pwd user = User.create(phone, pwd) return Auth.get_login_token(user)
def login_code_handler(r): phone = r.phone user = User.get_by_phone(phone) return Auth.get_login_token(user)
def login_phone_pwd_handler(r): phone = r.d.phone pwd = r.d.pwd user = User.authenticate(None, phone, pwd) return Auth.get_login_token(user)