Ejemplo n.º 1
0
def mark_user_email_verified(user, time=None):
    time = time or utcnow()
    if user.email_verified_at:
        raise UpdateError('Already verified')

    update_user(
        user,
        email_verified_at=utcnow(),
    )
    return user
Ejemplo n.º 2
0
    def GetFoo(self, request, context):
        foo = Foo()
        foo.id = request.id
        foo.created_at = utcnow()
        foo.name = 'Foo'

        return serializers.serialize_foo(foo)
Ejemplo n.º 3
0
def update_user_password(user, password):
    if config.REQUIRE_STRONG_PASSWORDS:
        check_password_strength(password)

    password_hash = hash_password(password)
    user_repo.update_user(user, password=password_hash, password_updated_at=utcnow())
    return user
Ejemplo n.º 4
0
def _get_expiration_params(expiration_seconds=None):
    expiration_seconds = expiration_seconds or DEFAULT_SESSION_EXPIRATION_SECONDS

    now = utcnow()
    expires_at = now + timedelta(seconds=expiration_seconds)
    expiration_timestamp = int(round(expires_at.timestamp()))

    return EasyDict(
        datetime=now,
        seconds=expiration_seconds,
        timestamp=expiration_timestamp,
    )
def create_user(email, password=None, email_verified=False, **fields):
    args = dict(email=email)
    args.update(fields)
    if password:
        password_hash = hash_password(password)
        args.update(password=password_hash)

    if email_verified:
        args.update(email_verified_at=utcnow())

    user = user_repo.create_user(**args)

    return user
Ejemplo n.º 6
0
def create_user(
    email,
    password=None,
    email_verified_at=None,
    commit=True
) -> User:
    user = User(
        email=email,
        email_verified_at=email_verified_at,
        password=password,
    )
    if password:
        user.password_updated_at = utcnow()

    with session_commit(exception=CreateError, commit=commit) as session:
        session.add(user)

    return user
Ejemplo n.º 7
0
def heartbeat():
    logger.info('Heartbeat %s', utcnow())