VC: Fix error on clone page for legacy-ID events
[cds-indico.git] / indico / modules / auth / blueprint.py
blobf3ba9a6561c8175908cdebb8b941d28b45d40b75
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 from __future__ import unicode_literals
19 from flask import request
21 from indico.modules.auth.controllers import (RHLogin, RHLoginForm, RHLogout, RHRegister, RHLinkAccount,
22 RHResetPassword, RHAccounts, RHRemoveAccount)
23 from indico.web.flask.util import make_compat_redirect_func
24 from indico.web.flask.wrappers import IndicoBlueprint
26 auth_blueprint = _bp = IndicoBlueprint('auth', __name__, template_folder='templates')
29 _bp.add_url_rule('/login/', 'login', RHLogin, methods=('GET', 'POST'))
30 _bp.add_url_rule('/login/<provider>/', 'login', RHLogin)
31 _bp.add_url_rule('/login/<provider>/form', 'login_form', RHLoginForm)
32 _bp.add_url_rule('/login/<provider>/link-account', 'link_account', RHLinkAccount, methods=('GET', 'POST'))
33 _bp.add_url_rule('/logout/', 'logout', RHLogout, methods=('GET', 'POST'))
35 _bp.add_url_rule('/register/', 'register', RHRegister, methods=('GET', 'POST'), defaults={'provider': None})
36 _bp.add_url_rule('/register/<provider>', 'register', RHRegister, methods=('GET', 'POST'))
38 _bp.add_url_rule('/reset-password/', 'resetpass', RHResetPassword, methods=('GET', 'POST'))
40 with _bp.add_prefixed_rules('/user/<int:user_id>', '/user'):
41 _bp.add_url_rule('/accounts/', 'accounts', RHAccounts, methods=('GET', 'POST'))
42 _bp.add_url_rule('/accounts/<identity>/remove/', 'remove_account', RHRemoveAccount, methods=('POST',))
45 @_bp.url_defaults
46 def _add_user_id(endpoint, values):
47 if endpoint in {'auth.accounts', 'auth.remove_account'} and 'user_id' not in values:
48 values['user_id'] = request.view_args.get('user_id')
51 # Legacy URLs
52 auth_compat_blueprint = _compat_bp = IndicoBlueprint('compat_auth', __name__)
53 _compat_bp.add_url_rule('/user/login', 'login', make_compat_redirect_func(_bp, 'login'))
54 _compat_bp.add_url_rule('/user/register', 'register', make_compat_redirect_func(_bp, 'register'))