Commit 8ef85758 by x

store: Fixed new user creation

parent 6841879c
...@@ -11,7 +11,7 @@ import os ...@@ -11,7 +11,7 @@ import os
import json import json
import base64 import base64
def estabilish_store_user(user): def estabilish_store_user(request, user):
try: try:
details = request.user.userclouddetails_set.all()[0] details = request.user.userclouddetails_set.all()[0]
password = details.smb_password password = details.smb_password
...@@ -22,14 +22,14 @@ def estabilish_store_user(user): ...@@ -22,14 +22,14 @@ def estabilish_store_user(user):
except: except:
return HttpResponse('Can not acces to django database!', status_code=404) return HttpResponse('Can not acces to django database!', status_code=404)
#Create user #Create user
if not StoreApi.createuser(user, password, key_list, str(quota)): if not StoreApi.createuser(user, password, key_list, str(quota)):
return HttpResponse('User does not exist on store! And could not create!') return HttpResponse('User does not exist on store! And could not create!')
@login_required @login_required
def index(request): def index(request):
user = request.user.username user = request.user.username
if StoreApi.userexist(user) != True: if StoreApi.userexist(user) != True:
estabilish_store_user(user) estabilish_store_user(request, user)
#UpdateAuthorizationInfo #UpdateAuthorizationInfo
try: try:
auth=request.POST['auth'] auth=request.POST['auth']
...@@ -41,14 +41,14 @@ def index(request): ...@@ -41,14 +41,14 @@ def index(request):
key_list.append(key.key) key_list.append(key.key)
except: except:
return HttpResponse('Can not acces to django database!', status_code=404) return HttpResponse('Can not acces to django database!', status_code=404)
if not StoreApi.updateauthorizationinfo(user,password,key_list): if not StoreApi.updateauthorizationinfo(user, password, key_list):
return HttpResponse('Can not update authorization information!') return HttpResponse('Can not update authorization information!')
except: except:
pass pass
#Download handler #Download handler
try: try:
dl = request.POST['dl'] dl = request.POST['dl']
return redirect(StoreApi.requestdownload(user,dl)) return redirect(StoreApi.requestdownload(user, dl))
except: except:
pass pass
#Upload handler #Upload handler
...@@ -87,7 +87,7 @@ def index(request): ...@@ -87,7 +87,7 @@ def index(request):
def ajax_listfolder(request): def ajax_listfolder(request):
user = request.user.username user = request.user.username
if StoreApi.userexist(user) != True: if StoreApi.userexist(user) != True:
estabilish_store_user(user) estabilish_store_user(request, user)
path = '/' path = '/'
try: try:
path = request.POST['path'] path = request.POST['path']
...@@ -102,7 +102,7 @@ def ajax_listfolder(request): ...@@ -102,7 +102,7 @@ def ajax_listfolder(request):
def ajax_quota(request): def ajax_quota(request):
user = request.user.username user = request.user.username
if StoreApi.userexist(user) != True: if StoreApi.userexist(user) != True:
estabilish_store_user(user) estabilish_store_user(request, user)
return HttpResponse(json.dumps(StoreApi.requestquota(user))) return HttpResponse(json.dumps(StoreApi.requestquota(user)))
#return HttpResponse(json.dumps({'Used':20,'Soft':160,'Hard':200})) #return HttpResponse(json.dumps({'Used':20,'Soft':160,'Hard':200}))
......
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 sign in to comment