def create_user(self, account, password, nickname, email, qq, mobile, fee_account_name, fee_account_num): # user_id = self.__uuid_data_factory.get_short_uuid() salt = utils.my_random_string(10) user_id = self.__user_data_factory.create_zone_source( # user_id=user_id, account=account, password=self.get_hashed_password(password, salt), nickname=nickname, salt=salt, email=email, qq=qq, mobile=mobile, fee_mode=USER_DEFAULT_FEE_MODE, fee_account_name=fee_account_name, fee_account_num=fee_account_num, source=USER_SOURCE_REGISTE, user_status=USER_STATUS_DISABLED, manager=USER_REGISTE_DEFAULT_MANAGER, ) if user_id: token = self.create_user_token(user_id) return user_id, token else: return None, None
def reset_user_pass(self, user_id, password): salt = utils.my_random_string(10) result_user_id = self.__admin_user_data_factory.update_admin_user( admin_user_id=user_id, password=self.get_hashed_password(password, salt), salt=salt, ) if result_user_id: return result_user_id else: return None
def check_nickname_default(self, nickname): """ :param nickname: :return: 0 成功 1 存在违规关键字 2 昵称长度超出限制长度 3 用户名存在 4 用户名为空 """ flag = 4 if nickname: nickname = nickname.replace('\n', '') nickname = nickname.replace('\r', '') nickname = nickname.replace('\t', '') nickname = nickname.replace(' ', '') try: nickname = virname_re.sub('', nickname) nickname = nickname.strip() except Exception as e: logging.warning(traceback.format_exc()) if not self.check_disallowed_words_in_nickname(nickname): if len(nickname) <= USER_MAX_ALLOWED_NICKNAME_LENGTH: user_info = self.__user_data_factory.get_user_info_by_nickname(nickname) if user_info: if len(nickname) <= 12: flag = 0 nickname += utils.my_random_string(3) else: # 用户名存在 flag = 3 else: flag = 0 else: # 用户长度超限 flag = 2 else: # 用户昵称存在违规关键字 flag = 1 return flag, nickname
def __generate_reset_token(cls, channel='website'): if channel == 'website': token = utils.my_random_string(30) else: token = utils.my_random_string(32) return token