Commit 4827eed4 by François C.

Add data when external login

parent 1dde715e
Pipeline #2224 passed with stage
in 1 minute 22 seconds
...@@ -160,6 +160,15 @@ class CagetteMember(models.Model): ...@@ -160,6 +160,15 @@ class CagetteMember(models.Model):
data['auth_token'] = hashlib.sha256(auth_token_seed.encode('utf-8')).hexdigest() data['auth_token'] = hashlib.sha256(auth_token_seed.encode('utf-8')).hexdigest()
data['token'] = hashlib.sha256(coop['create_date'].encode('utf-8')).hexdigest() data['token'] = hashlib.sha256(coop['create_date'].encode('utf-8')).hexdigest()
data['coop_state'] = coop_state data['coop_state'] = coop_state
if external is True:
from outils.functions import extract_firstname_lastname
name_sep = getattr(settings, 'SUBSCRIPTION_NAME_SEP', ' ')
name_elts = extract_firstname_lastname(coop['name'], name_sep)
data['lastname'] = name_elts['lastname']
if name_elts['firstname'] != name_elts['lastname']:
data['firstname'] = name_elts['firstname']
else:
data['firstname'] = ''
if not ('auth_token' in data): if not ('auth_token' in data):
data['failure'] = True data['failure'] = True
......
...@@ -450,6 +450,5 @@ def save_partner_info(request): ...@@ -450,6 +450,5 @@ def save_partner_info(request):
def external_login(request): def external_login(request):
"""Post request send from external login page, such as Question2Answer.""" """Post request send from external login page, such as Question2Answer."""
# TODO : Allow only known host (based on domain ? key ?) # TODO : Allow only known host (based on domain ? key ?)
res = {} res = {'credentials': CagetteMember.get_credentials(request, external=True)}
CagetteMember.get_credentials(request, external=True)
return JsonResponse(res, safe=False) 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