add platform to userprofile when login
This commit is contained in:
parent
56226f0d1b
commit
4aba9e8331
|
@ -12,7 +12,6 @@ import os
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
|
||||
from polls.models import Notice, VerifyCode
|
||||
from polls.utils import generate_code, sent_sms_code
|
||||
from dashboard.models import Organization, Userprofile
|
||||
|
@ -38,6 +37,7 @@ def polls_login(request):
|
|||
if request.method == 'POST':
|
||||
phone = request.POST.get('phone')
|
||||
password = request.POST.get('password')
|
||||
platform = request.POST.get('platform', 'android')
|
||||
UserModel = get_user_model()
|
||||
user = UserModel.objects.filter(username=phone).first()
|
||||
if not user:
|
||||
|
@ -63,6 +63,8 @@ def polls_login(request):
|
|||
result['thumbnail'] = request.build_absolute_uri(
|
||||
profile.image.url) if profile.image else None
|
||||
result['organization'] = profile.organization.name
|
||||
profile.platform = platform
|
||||
profile.save()
|
||||
return JsonResponse({'status': 'success', 'message': result})
|
||||
else:
|
||||
return JsonResponse({'status': 'error', 'message': '用户名或密码错误'})
|
||||
|
|
Loading…
Reference in New Issue