AiC and REST login
[myslice.git] / rest / credentials.py
1 from django.http                    import HttpResponse
2 from portal.actions import clear_user_creds
3 import json
4
5 def dispatch(request, action):
6     
7     if (action == 'clear') :
8         res=[]
9         emails = request.POST.getlist('emails[]')
10         if not emails:
11             emails = request.GET.getlist('emails[]')
12         if emails :
13             for email in emails :
14                 try :
15                     clear = clear_user_creds(request, email)
16                     if clear is not None:
17                         res.append(clear)
18                 except :
19                     pass
20         
21         if not res :
22             ret = { "ret" : 1, "emails" : emails }
23         else :
24             ret = { "ret" : 0 }
25     
26     return HttpResponse(json.dumps(ret), content_type="application/json")