Пример #1
0
def change_ss_port(request):
    """
    随机重置用户用端口
    返回是否成功
    """
    user = request.user.ss_user
    # 找到端口池中最大的端口
    port = Suser.get_random_port()
    user.port = port
    user.save()
    registerinfo = {
        "title": "修改成功!",
        "subtitle": "端口修改为:{}!".format(port),
        "status": "success",
    }
    return JsonResponse(registerinfo)
Пример #2
0
def change_ss_port(request):
    '''
    随机重置用户用端口
    返回是否成功
    '''
    user = request.user.ss_user
    # 找到端口池中最大的端口
    port = Suser.get_random_port()
    user.port = port
    user.save()
    registerinfo = {
        'title': '修改成功!',
        'subtitle': '端口修改为:{}!'.format(port),
        'status': 'success',
    }
    return JsonResponse(registerinfo)
Пример #3
0
 def add_new_user(cls, cleaned_data):
     from apps.ssserver.models import Suser
     with transaction.atomic():
         username = cleaned_data['username']
         email = cleaned_data['email']
         password = cleaned_data['password1']
         invitecode = cleaned_data['invitecode']
         user = cls.objects.create_user(username, email, password)
         code = InviteCode.objects.get(code=invitecode)
         code.isused = True
         code.save()
         # 将user和ssuser关联
         Suser.objects.create(user_id=user.id, port=Suser.get_random_port())
         # 绑定邀请人
         user.invited_by = code.code_id
         user.invitecode = invitecode
         user.save()
         return user