Commit 1dde715e by François C.

Adaptations pour connexion via formulaire externe

parent 9afd5f37
Pipeline #2223 passed with stage
in 1 minute 32 seconds
...@@ -121,7 +121,7 @@ class CagetteMember(models.Model): ...@@ -121,7 +121,7 @@ class CagetteMember(models.Model):
'id DESC') 'id DESC')
@staticmethod @staticmethod
def get_credentials(request): def get_credentials(request, external=False):
import hashlib import hashlib
data = {} data = {}
...@@ -171,7 +171,7 @@ class CagetteMember(models.Model): ...@@ -171,7 +171,7 @@ class CagetteMember(models.Model):
data['errnum'] = 2 data['errnum'] = 2
# data['res'] = res # data['res'] = res
elif 'token' in request.COOKIES and 'id' in request.COOKIES: elif external is False and 'token' in request.COOKIES and 'id' in request.COOKIES:
api = OdooAPI() api = OdooAPI()
cond = [['id', '=', request.COOKIES['id']]] cond = [['id', '=', request.COOKIES['id']]]
fields = ['create_date','email'] fields = ['create_date','email']
...@@ -187,6 +187,7 @@ class CagetteMember(models.Model): ...@@ -187,6 +187,7 @@ class CagetteMember(models.Model):
else: else:
data['failure'] = True data['failure'] = True
if not ('failure' in data): if not ('failure' in data):
if external is False:
data['login'] = login data['login'] = login
c_db_data = CagetteMember.get_couchdb_data(login) c_db_data = CagetteMember.get_couchdb_data(login)
if len(c_db_data) > 0 and 'validation_state' in c_db_data: if len(c_db_data) > 0 and 'validation_state' in c_db_data:
......
...@@ -71,4 +71,6 @@ urlpatterns = [ ...@@ -71,4 +71,6 @@ urlpatterns = [
url(r'^update_members_makeups$', admin.update_members_makeups), url(r'^update_members_makeups$', admin.update_members_makeups),
url(r'^get_member_info/(\d+)$', admin.get_member_info), url(r'^get_member_info/(\d+)$', admin.get_member_info),
url(r'^get_attached_members$', admin.get_attached_members), url(r'^get_attached_members$', admin.get_attached_members),
# External login
url(r'^external_login$', views.external_login)
] ]
...@@ -443,3 +443,13 @@ def save_partner_info(request): ...@@ -443,3 +443,13 @@ def save_partner_info(request):
else: else:
res['error'] = "Forbidden" res['error'] = "Forbidden"
return JsonResponse(res, safe=False) return JsonResponse(res, safe=False)
### External login
@csrf_exempt
def external_login(request):
"""Post request send from external login page, such as Question2Answer."""
# TODO : Allow only known host (based on domain ? key ?)
res = {}
CagetteMember.get_credentials(request, external=True)
return JsonResponse(res, safe=False)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment