Esempio n. 1
0
    def _process_imp(self):
        # 保存到数据库
        code = random.randint(1000, 9999)
        SmsDao.insert(self.para_map["phone"], code, constant.SMS_LOGIN)

        # 发送短信
        send_sms_task.send_login_sms.delay(self.para_map["phone"], code)

        self.ret_code = errcode.NO_ERROR
        self.ret_msg = 'ok'

        return
Esempio n. 2
0
    def _process_imp(self):
        # 用户必须存在
        user = UserDao.get_by_phone(self.para_map["phone"])
        if not user:
            self.ret_code = errcode.SEND_SMS_ERROR
            self.ret_msg = 'user not exist'
            return

        # 保存到数据库
        code = random.randint(1000, 9999)
        SmsDao.insert(self.para_map["phone"], code, constant.SMS_FORGET_PASS)

        # 发送短信
        send_sms_task.send_forget_pass_sms.delay(self.para_map["phone"], code)

        self.ret_code = errcode.NO_ERROR
        self.ret_msg = 'ok'

        return
Esempio n. 3
0
    def _process_imp(self):

        # 不存在该用户
        user = UserDao.get_by_phone(self.para_map["phone"])
        if not user:
            self.ret_code = errcode.USER_NOT_EXIST
            self.ret_msg = 'phone is not exist'
            return

        # 检查短信验证码
        sms = SmsDao.get_by_phone_and_code(self.para_map["phone"],
                                           self.para_map["code"])
        if not sms:
            self.ret_code = errcode.SEND_SMS_ERROR
            self.ret_msg = 'code is error'
            return

        phone = self.para_map["phone"]
        cuid = self.common_param["cuid"]
        device_type = self.common_param["device_type"]
        device_os = self.common_param["device_os"]
        app_version = self.common_param["app_version"]
        channel = self.common_param["channel"]

        # 刷新DB的设备信息
        UserDao.update(
            {
                "phone": phone,
                "cuid": cuid,
                "device_type": device_type,
                "device_os": device_os,
                "app_version": app_version,
                "channel": channel
            },
            where_col="phone",
            where_col_str=True)

        # 生成新的sid
        new_sid = app_token_util.make_sid(user["source"], user["id"],
                                          device_type, cuid)

        self.ret_code = errcode.NO_ERROR
        self.ret_msg = 'ok'
        self.ret_data = {
            "user": user,
            "sid": new_sid,
        }

        return
Esempio n. 4
0
    def _process_imp(self):

        # 手机号已经存在
        user = UserDao.get_by_phone(self.para_map["phone"])
        if user:
            self.ret_code = errcode.USER_ALREADY_EXIST
            self.ret_msg = 'phone is already exist'
            return

        # 检查短信验证码
        sms = SmsDao.get_by_phone_and_code(self.para_map["phone"],
                                           self.para_map["code"])
        if not sms:
            self.ret_code = errcode.SEND_SMS_ERROR
            self.ret_msg = 'code is error'
            return

        phone = self.para_map["phone"]
        cuid = self.common_param["cuid"]
        device_type = self.common_param["device_type"]
        device_os = self.common_param["device_os"]
        app_version = self.common_param["app_version"]
        channel = self.common_param["channel"]

        user_id = UserDao.insert({
            "phone": phone,
            "cuid": cuid,
            "device_type": device_type,
            "device_os": device_os,
            "app_version": app_version,
            "channel": channel
        })
        user = UserDao.get_by_id(user_id)

        # 生成新的sid,初次注册默认是用户,要上传资料审核才能成为医生
        new_sid = app_token_util.make_sid(constant.USER_SOURCE_LOGIN_USER,
                                          user_id, device_type, cuid)

        self.ret_code = errcode.NO_ERROR
        self.ret_msg = 'ok'
        self.ret_data = {
            "user": user,
            "sid": new_sid,
        }

        return
Esempio n. 5
0
    def _process_imp(self):
        # 已经有用户使用该手机,不能被绑定
        user = UserDao.get_by_phone(self.para_map["phone"])
        if user:
            self.ret_code = errcode.USER_ALREADY_EXIST
            self.ret_msg = 'phone is already exist'
            return

        # 检查短信验证码
        sms = SmsDao.get_by_phone_and_code(self.para_map["phone"], self.para_map["code"])
        if not sms:
            self.ret_code = errcode.SEND_SMS_ERROR
            self.ret_msg = 'code is error'
            return

        phone = self.para_map["phone"]
        uid = self.para_map["uid"]
        cuid = self.common_param["cuid"]
        device_type = self.common_param["device_type"]

        UserDao.update({
            "phone": phone,
            "id": uid,
        }
        )
        user_info = UserDao.get_profile_by_phone(phone)

        # 生成新的sid
        new_sid = app_token_util.make_sid(user["source"], uid, device_type, cuid)

        self.ret_code = errcode.NO_ERROR
        self.ret_msg = 'ok'
        self.ret_data = {
            "user": user_info,
            "sid": new_sid,
        }

        return