source: OpenWorkouts-current/ow/__init__.py @ 8c2b094

current
Last change on this file since 8c2b094 was 76ebb1b, checked in by Borja Lopez <borja@…>, 5 years ago

(#29) Add user verification by email on signup.

From now on, when a new user signs up, we set the account into an "unverified"
state. In order to complete the signup procedure, the user has to click on a
link we send by email to the email address provided on signup.

IMPORTANT: A new dependency has been added, pyramid_mailer, so remember to
install it in any existing openworkouts environment (this is done automatically
if you use the ./bin/start script):

pip install pyramid_mailer

  • Property mode set to 100644
File size: 1.5 KB
Line 
1from pyramid.config import Configurator
2from pyramid_zodbconn import get_connection
3from pyramid.authentication import AuthTktAuthenticationPolicy
4from pyramid.authorization import ACLAuthorizationPolicy
5from pyramid.session import SignedCookieSessionFactory
6
7from .models import appmaker
8from .security import groupfinder
9
10
11def root_factory(request):  # pragma: no cover
12    conn = get_connection(request)
13    return appmaker(conn.root())
14
15
16def main(global_config, **settings):  # pragma: no cover
17    """
18    This function returns a Pyramid WSGI application.
19    """
20    session_factory = SignedCookieSessionFactory(
21        secret=settings['session.secret'],
22        cookie_name='ow-session')
23
24    authn_policy = AuthTktAuthenticationPolicy(
25        secret=settings['auth.secret'],
26        callback=groupfinder,
27        hashalg='sha512')
28
29    authz_policy = ACLAuthorizationPolicy()
30
31    config = Configurator(root_factory=root_factory, settings=settings)
32    config.set_authentication_policy(authn_policy)
33    config.set_authorization_policy(authz_policy)
34    config.set_session_factory(session_factory)
35    config.include('pyramid_chameleon')
36    config.include('pyramid_tm')
37    config.include('pyramid_retry')
38    config.include('pyramid_zodbconn')
39    config.include('pyramid_mailer')
40    config.add_static_view('static', 'static', cache_max_age=3600)
41    config.add_translation_dirs(
42        'ow:locale',
43        'formencode:i18n')
44    config.scan()
45    return config.make_wsgi_app()
Note: See TracBrowser for help on using the repository browser.