Skip to content

Commit

Permalink
Added last login API
Browse files Browse the repository at this point in the history
  • Loading branch information
manojp3 committed Jul 15, 2024
1 parent f77a765 commit 5f53fdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/djangoapps/student/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
re_path(r'^extras/reset_password_link', views.extras_reset_password_link, name = "extras_reset_password_link"),

re_path(r'^extras/get_user_enrolled_courses', views.extras_get_user_enrolled_courses, name = "extras_get_user_enrolled_courses"),
re_path(r'^extras/get_last_login', views.extras_get_last_login, name = "extras_get_last_login"),

re_path(r'^email_confirm/(?P<key>[^/]*)$', views.confirm_email_change, name='confirm_email_change'),

Expand Down
20 changes: 19 additions & 1 deletion common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,4 +1354,22 @@ def _get_active_inactive_courses(user):
user_active_inactive_courses.update({user_course["course_details"]["course_id"] : "Active"})
else:
user_active_inactive_courses.update({user_course["course_details"]["course_id"] : "Dropped"})
return user_active_inactive_courses
return user_active_inactive_courses

@csrf_exempt
def extras_get_last_login(request):
secret_key = configuration_helpers.get_value("EXTRAS_USER_DETAILS_TOKEN", "MZi7J7jArBgY8YoSFfvrpIqH65LXIuNA")
user_email = request.POST.get("email", "")
token = request.POST.get("token", "")

if secret_key != token:
return JsonResponse({})
if user_email == "" or user_email == None:
return JsonResponse({"Error": "Enter a valid Email"})

try:
user = User.objects.get(email = user_email)
return JsonResponse({"email": user.email, "username": user.username, "first_name": user.first_name, "last_name": user.last_name, "last_login": user.last_login})
except Exception as e:
log.info(e)
return JsonResponse({"ERROR": "Something went wrong"})

0 comments on commit 5f53fdc

Please sign in to comment.