Example #1
0
def create_user():
    auth_request = request.get_json()

    mail, password = get_user_data_from_request(auth_request)

    User.create(email=mail, password=password)
    return {'success': 'User has been registered'}, 200
Example #2
0
def test5():
    with app.app_context():
        u = User()
        setattr(u, User.code.key, "Test3")
        u.name = "Test User"
        session.add(u)
        session.commit()
        print(getattr(u, "id"))
Example #3
0
def search(term, only_uuid=False, only_userid=False, only_name=False):
    if only_uuid:
        query = User.objects(Q(uuid__iexact=term))
    elif only_userid:
        query = User.objects(Q(userid__icontains=term))
    elif only_name:
        query = User.objects(Q(name__icontains=term))
    else:
        query = User.objects(
            Q(uuid__iexact=term) | Q(userid__icontains=term)
            | Q(name__icontains=term))
    return query
Example #4
0
def new_user(email):
    uuid = secrets.token_hex(16)
    try:
        newUserPublic = User(uuid=uuid)
        newUserPrivate = UserPrivate(uuid=uuid,
                                     registerationTime=time.time(),
                                     email=email)
        newUserPrivacy = UserPrivacy(uuid=uuid)
        newUserPrivate.save()
        newUserPrivacy.save()
        newUserPublic.save()
        return uuid
    except:
        return False
Example #5
0
 def get_user(self):
     if self.userinfo:
         _user = User.get(id=self.userinfo.id)
     else:
         _user = Dict()
     logger.info('_user: %s' % _user)
     return _user
Example #6
0
def login_user():
    auth_request = request.get_json()

    mail, password = get_user_data_from_request(auth_request)

    user_id = User.verify(mail, password)

    access_token = create_access_token(identity=user_id)
    refresh_token = create_refresh_token(identity=user_id)
    return {'access_token': access_token, 'refresh_token': refresh_token}, 200
Example #7
0
    def test_password_written(self):
        password = '******'
        invalid_password = '******'
        mail = "*****@*****.**"

        self.request({"email": "[email protected] ", "password": password}, self.endpoint)
        with app.app_context():
            password_in_db = User.get_one(mail).password

        self.assertTrue(checkpw(password.encode(), password_in_db.encode()))
        self.assertFalse(checkpw(invalid_password.encode(), password_in_db.encode()))
Example #8
0
def get_user_info_by_uuid(uuid):
    return User.objects(uuid__iexact=uuid).first()