]> git.openstreetmap.org Git - chef.git/blob - cookbooks/osqa/files/default/osmauth/authentication.py
7c8e702791b83e5128f827663505a6600960a0b0
[chef.git] / cookbooks / osqa / files / default / osmauth / authentication.py
1 from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext, InvalidAuthentication
2 from forms import OpenStreetMapLoginForm
3
4 class OpenStreetMapAuthConsumer(AuthenticationConsumer):
5     def process_authentication_request(self, request):
6         form_auth = OpenStreetMapLoginForm(request.POST)
7
8         if form_auth.is_valid():
9             request.session["auth_consumer_data"] = form_auth.get_user_data()
10             return form_auth.get_user()
11         else:
12             raise InvalidAuthentication(" ".join(form_auth.errors.values()[0]))
13
14     def get_user_data(self, key):
15         return {}
16
17 class OpenStreetMapAuthContext(ConsumerTemplateContext):
18     mode = 'TOP_STACK_ITEM'
19     weight = 0
20     human_name = 'OpenStreetMap Login'
21     stack_item_template = 'modules/osmauth/loginform.html'