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):
'id DESC')
@staticmethod
def get_credentials(request):
def get_credentials(request, external=False):
import hashlib
data = {}
......@@ -171,7 +171,7 @@ class CagetteMember(models.Model):
data['errnum'] = 2
# 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()
cond = [['id', '=', request.COOKIES['id']]]
fields = ['create_date','email']
......@@ -187,10 +187,11 @@ class CagetteMember(models.Model):
else:
data['failure'] = True
if not ('failure' in data):
data['login'] = login
c_db_data = CagetteMember.get_couchdb_data(login)
if len(c_db_data) > 0 and 'validation_state' in c_db_data:
data['validation_state'] = c_db_data['validation_state']
if external is False:
data['login'] = login
c_db_data = CagetteMember.get_couchdb_data(login)
if len(c_db_data) > 0 and 'validation_state' in c_db_data:
data['validation_state'] = c_db_data['validation_state']
# print(str(data))
return data
......
......@@ -71,4 +71,6 @@ urlpatterns = [
url(r'^update_members_makeups$', admin.update_members_makeups),
url(r'^get_member_info/(\d+)$', admin.get_member_info),
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):
else:
res['error'] = "Forbidden"
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