示例#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
示例#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"))
示例#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
示例#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
示例#5
0
文件: session.py 项目: jie/homegate
 def get_user(self):
     if self.userinfo:
         _user = User.get(id=self.userinfo.id)
     else:
         _user = Dict()
     logger.info('_user: %s' % _user)
     return _user
示例#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
示例#7
0
文件: test_app.py 项目: Glaih/TODOEd
    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()))
示例#8
0
def get_user_info_by_uuid(uuid):
    return User.objects(uuid__iexact=uuid).first()